npm-normalize-package-bin
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -13,2 +13,4 @@ // pass in a manifest with a 'bin' field here, and it'll turn it | ||
const normalizeString = pkg => { | ||
if (!pkg.name) | ||
return removeBin(pkg) | ||
pkg.bin = { [pkg.name]: pkg.bin } | ||
@@ -15,0 +17,0 @@ return normalizeObject(pkg) |
{ | ||
"name": "npm-normalize-package-bin", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Turn any flavor of allowable package.json bin into a normalized object", | ||
@@ -5,0 +5,0 @@ "repository": "git+https://github.com/npm/npm-normalize-package-bin", |
@@ -31,2 +31,3 @@ const normalize = require('../') | ||
array: [1,2,3], | ||
func: function () {}, | ||
} } | ||
@@ -45,2 +46,3 @@ const expect = { name: 'hello', version: 'world', bin: { | ||
'/etc/glorb/baz': '/etc/passwd', | ||
'/etc/passwd:/bin/usr/exec': '/etc/passwd', | ||
} } | ||
@@ -54,2 +56,3 @@ const expect = { | ||
baz: 'etc/passwd', | ||
exec: 'etc/passwd', | ||
} | ||
@@ -56,0 +59,0 @@ } |
@@ -24,1 +24,15 @@ const normalize = require('../') | ||
}) | ||
t.test('double path', async t => { | ||
const pkg = { name: 'hello', version: 'world', bin: '/etc/passwd:/bin/usr/exec' } | ||
const expect = { name: 'hello', version: 'world', bin: { hello: 'etc/passwd:/bin/usr/exec' } } | ||
t.strictSame(normalize(pkg), expect) | ||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') | ||
}) | ||
t.test('string with no name', async t => { | ||
const pkg = { bin: 'foobar.js' } | ||
const expect = {} | ||
t.strictSame(normalize(pkg), expect) | ||
t.strictSame(normalize(normalize(pkg)), expect, 'double sanitize ok') | ||
}) |
Sorry, the diff of this file is too big to display
131250
3804