Skip to content

Commit

Permalink
Fix scoped bin paths (#2163)
Browse files Browse the repository at this point in the history
* Add failing tests for bin path normalisation from scoped package name

* Add fix for bin normalisation for scoped packages
  • Loading branch information
Greg Poole authored and bestander committed Dec 7, 2016
1 parent 0664103 commit 8a12b1b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@scope/foo",
"bin": "bar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@scope/foo",
"version": "",
"bin": {
"foo": "bar"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["@scope/foo: No license field"]
4 changes: 3 additions & 1 deletion src/util/normalize-manifest/fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ export default async function (
// 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') {
info.bin = {[info.name]: info.bin};
// Remove scoped package name for consistency with NPM's bin field fixing behaviour
const name = info.name.replace(/^@[^\/]+\//, '');
info.bin = {[name]: info.bin};
}

// bundleDependencies is an alias for bundledDependencies
Expand Down

0 comments on commit 8a12b1b

Please sign in to comment.