Skip to content

Commit

Permalink
fix(npx): properly look for local bins when there are more than one (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar authored Nov 16, 2022
1 parent a351685 commit cc0ad27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions workspaces/libnpmexec/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const exec = async (opts) => {
return run()
}

const needPackageCommandSwap = (args.length > 0) && (packages.length === 0)
let needPackageCommandSwap = (args.length > 0) && (packages.length === 0)
// If they asked for a command w/o specifying a package, see if there is a
// bin that directly matches that name:
// - in the local package itself
Expand All @@ -126,9 +126,11 @@ const exec = async (opts) => {
if (localManifest?.bin?.[args[0]]) {
// we have to install the local package into the npx cache so that its
// bin links get set up
flatOptions.installLinks = false
// args[0] will exist when the package is installed
packages.push(path)
yes = true
flatOptions.installLinks = false
needPackageCommandSwap = false
} else {
const dir = dirname(dirname(localBin))
const localBinPath = await localFileExists(dir, args[0], '/')
Expand Down
1 change: 1 addition & 0 deletions workspaces/libnpmexec/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ t.test('bin in local pkg', async t => {
const pkg = {
name: '@npmcli/local-pkg-bin-test',
bin: {
b: 'echo this is something else',
a: 'local-bin-test.js',
},
}
Expand Down

0 comments on commit cc0ad27

Please sign in to comment.