Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(npx): properly look for local bins when there are more than one #5842

Merged
merged 1 commit into from Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions workspaces/libnpmexec/lib/index.js
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
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',
lukekarrys marked this conversation as resolved.
Show resolved Hide resolved
a: 'local-bin-test.js',
},
}
Expand Down