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

Binaries are not set globally when using directories.bin #978

Open
felipecrs opened this issue Apr 24, 2021 · 2 comments
Open

Binaries are not set globally when using directories.bin #978

felipecrs opened this issue Apr 24, 2021 · 2 comments
Labels

Comments

@felipecrs
Copy link
Contributor

felipecrs commented Apr 24, 2021

Binaries can also be set using directories.bin and not only bin. bats is an example of it.

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#directoriesbin

To reproduce:

volta --version
1.0.4npm --version
7.11.1npm install --global bats

added 1 package, and audited 2 packages in 2s

found 0 vulnerabilitieswhich bats
bats not founddocker run --rm -it node:14 bash -xc 'npm install --global bats && bats --version'
+ npm install --global bats
/usr/local/bin/bats -> /usr/local/lib/node_modules/bats/bin/bats
+ bats@1.3.0
added 1 package from 1 contributor in 0.353s
+ bats --version
Bats 1.3.0

The above works fine when not using volta.

References bats-core/bats-core#430.

@charlespierce
Copy link
Contributor

Hi @felipecrs thanks for reporting! That does appear to be a use-case that we missed!

@felipecrs
Copy link
Contributor Author

Just to add, this should probably be fixed somewhere in between this code:

// If the bin list contains only an empty string, that means `bin` was a string value,
// rather than a map. In that case, to match `npm`s behavior, we use the name of the package
// as the bin name.
// Note: For a scoped package, we should remove the scope and only use the package name
if manifest.bin == [""] {
manifest.bin.pop();
manifest.bin.push(default_binary_name(&manifest.name));
}

The directories.bin key in package.json needs to be taken into account, and, if set, Volta should look for all files under the directory specified by directories.bin and add them to the manifest.bin list before exiting this function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants