Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions __tests__/__snapshots__/normalize-manifest.js.snap
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "foo",
"bin": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "foo",
"version": "",
"bin": ""
}
2 changes: 1 addition & 1 deletion src/util/normalize-manifest/fix.js
Original file line number Diff line number Diff line change
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