Permalink
Browse files

Actually reproduce npm#17781 in the same conditions

  • Loading branch information...
fasterthanlime committed Jul 25, 2017
1 parent 68b58bd commit 8161924bf9d177521193fa2b9ff0c8bdf14b58a8
Showing with 35 additions and 10 deletions.
  1. +1 −0 test/common-tap.js
  2. +34 −10 test/tap/prune-dev-dep-with-bins.js
View
@@ -67,6 +67,7 @@ exports.npm = function (cmd, opts, cb) {
var stdout = ''
var stderr = ''
// cmd = ['--inspect-brk=5858'].concat(cmd)
var child = spawn(nodeBin, cmd, opts)
if (child.stderr) {
@@ -11,30 +11,53 @@ var testdir = path.join(__dirname, path.basename(__filename, '.js'))
var fixture = new Tacks(
Dir({
node_modules: Dir({
'a': Dir({
'yes': Dir({
'package.json': File({
_requested: {
rawSpec: 'file:///mods/a'
rawSpec: 'file:///mods/yes'
},
dependencies: {},
bin: {
'some-helper': 'src/cli.js'
'yes': 'yes.js'
},
name: 'a',
name: 'yes',
version: '1.0.0'
}),
'cli.js': File('console.log("some helper v1.0.0")')
'yes.js': File('while (true) { console.log("y") }')
}),
'.bin': Dir({
'some-helper': File('#!/bin/sh\n# insert unixy npm wrapper script'),
'some-helper.cmd': File('REM insert windowsy npm wrapper script')
// verbose, but needed for `read-cmd-shim` to properly identify which
// package this belongs to
'yes': File(
'#!/bin/sh\n' +
'basedir=$(dirname "$(echo "$0" | sed -e \'s,\\\\,/,g\')")\n' +
'\n' +
'case `uname` in\n' +
' *CYGWIN*) basedir=`cygpath -w "$basedir"`;;\n' +
'esac\n' +
'\n' +
'if [ -x "$basedir/node" ]; then\n' +
' "$basedir/node" "$basedir/../yes/yes.js" "$@"\n' +
' ret=$?\n' +
'else\n' +
' node "$basedir/../yes/yes.js" "$@"\n' +
' ret=$?\n' +
'fi\n' +
'exit $ret\n'),
'yes.cmd': File(
'@IF EXIST "%~dp0\node.exe" (\n' +
'"%~dp0\\node.exe" "%~dp0\\..\\yes\\yes.js" %*\n' +
') ELSE (\n' +
'@SETLOCAL\n' +
'@SET PATHEXT=%PATHEXT:;.JS;=;%\n' +
'node "%~dp0\..\yes\yes.js" %*')
})
}),
'package.json': File({
name: 'test',
version: '1.0.0',
devDependencies: {
'a': 'file:///mods/a',
'yes': 'file:///mods/yes',
}
})
})
@@ -67,9 +90,10 @@ test('prune cycle in dev deps', function (t) {
common.npm(['prune', '--production', '--json'], {cwd: testdir}, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'prune finished successfully')
t.like(JSON.parse(stdout), {removed: [{name: 'a'}]}, 'removed the right modules')
t.like(JSON.parse(stdout), {removed: [{name: 'yes'}]}, 'removed the right modules')
var dirs = readdir(testdir + '/node_modules').sort()
t.same(dirs, [])
// bindirs are never removed, it's ok for them to remain after prune
t.same(dirs, ['.bin'])
t.end()
})
})

0 comments on commit 8161924

Please sign in to comment.