Skip to content

Commit af97edf

Browse files
committed
feat: update node_modules/.bin
Make the `add` and `link` commands update the "node_modules/.bin" directory.
1 parent 5f304a3 commit af97edf

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/add.ts

+20
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,26 @@ export const addPackages = async (
174174
replacedVersion =
175175
replacedVersion == localAddress ? '' : replacedVersion
176176
}
177+
178+
if (pkg.bin) {
179+
const binDir = join(workingDir, 'node_modules', '.bin')
180+
if (typeof pkg.bin === 'string') {
181+
fs.ensureDirSync(binDir)
182+
ensureSymlinkSync(
183+
join(destYalcCopyDir, pkg.bin),
184+
join(binDir, pkg.name)
185+
)
186+
} else if (typeof pkg.bin === 'object') {
187+
fs.ensureDirSync(binDir)
188+
for (const name in pkg.bin) {
189+
ensureSymlinkSync(
190+
join(destYalcCopyDir, name),
191+
join(binDir, pkg.bin[name])
192+
)
193+
}
194+
}
195+
}
196+
177197
const addedAction = options.link ? 'linked' : 'added'
178198
console.log(
179199
`Package ${pkg.name}@${

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface PackageManifest {
7373
name: string
7474
version: string
7575
private?: boolean
76-
files: string[]
76+
bin?: string | { [name: string]: string }
7777
dependencies?: { [name: string]: string }
7878
devDependencies?: { [name: string]: string }
7979
workspaces?: string[]

src/installations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'fs-extra'
22
import * as path from 'path'
3-
import { getStoreMainDir, values, readPackageManifest } from '.'
3+
import { getStoreMainDir, values } from '.'
44
import { readLockfile } from './lockfile'
55

66
export type PackageName = string & { __packageName: true }

0 commit comments

Comments
 (0)