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: handle empty bin strings #6515

Merged
merged 4 commits into from Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Fixes handling of empty string entries for bin in package.json

[#6515](https://github.com/yarnpkg/yarn/pull/6515) - [**Ryan Burrows**](https://github.com/rhburrows)

- Adds support for basic auth for registries with paths, such as artifactory

[#5322](https://github.com/yarnpkg/yarn/pull/5322) - [**Karolis Narkevicius**](https://twitter.com/KidkArolis)
Expand Down
6 changes: 6 additions & 0 deletions __tests__/__snapshots__/normalize-manifest.js.snap
Expand Up @@ -90,6 +90,12 @@ Array [
]
`;

exports[`empty bin string: empty bin string 1`] = `
Array [
"foo: No license field",
]
`;

exports[`engines array: engines array 1`] = `
Array [
"No license field",
Expand Down
@@ -0,0 +1,4 @@
{
"name": "foo",
"bin": ""
}
@@ -0,0 +1,5 @@
{
"name": "foo",
"version": "",
"bin": ""
}
2 changes: 1 addition & 1 deletion src/util/normalize-manifest/fix.js
Expand Up @@ -153,7 +153,7 @@ export default (async function(
// if the `bin` field is as string then expand it to an object with a single property
// based on the original `bin` field and `name field`
// { name: "foo", bin: "cli.js" } -> { name: "foo", bin: { foo: "cli.js" } }
if (typeof info.name === 'string' && typeof info.bin === 'string') {
if (typeof info.name === 'string' && typeof info.bin === 'string' && info.bin.length > 0) {
// Remove scoped package name for consistency with NPM's bin field fixing behaviour
const name = info.name.replace(/^@[^\/]+\//, '');
info.bin = {[name]: info.bin};
Expand Down