summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/gently-rm-linked-module.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap/gently-rm-linked-module.js')
-rw-r--r--deps/npm/test/tap/gently-rm-linked-module.js68
1 files changed, 26 insertions, 42 deletions
diff --git a/deps/npm/test/tap/gently-rm-linked-module.js b/deps/npm/test/tap/gently-rm-linked-module.js
index aeae71eee0..a9804cd792 100644
--- a/deps/npm/test/tap/gently-rm-linked-module.js
+++ b/deps/npm/test/tap/gently-rm-linked-module.js
@@ -46,7 +46,8 @@ var env = extend({}, process.env)
env.npm_config_prefix = linkedGlobal
var EXEC_OPTS = {
cwd: workingDir,
- env: env
+ env: env,
+ stdio: [0, 'pipe', 2]
}
test('setup', function (t) {
@@ -57,49 +58,32 @@ test('setup', function (t) {
})
test('install and link', function (t) {
+ var globalBin = resolve(linkedGlobal, isWindows ? '.' : 'bin', 'linked')
+ var globalModule = resolve(linkedGlobal, isWindows ? '.' : 'lib', 'node_modules', '@test', 'linked')
// link our test module into the global folder
- common.npm(
- [
- '--loglevel', 'error',
- 'link',
- toInstall
- ],
- EXEC_OPTS,
- function (er, code) {
- if (er) throw er
- t.is(code, 0, 'link succeeded')
- var globalBin = resolve(linkedGlobal, isWindows ? '.' : 'bin', 'linked')
- var globalModule = resolve(linkedGlobal, isWindows ? '.' : 'lib', 'node_modules', '@test', 'linked')
- var localBin = resolve(workingDir, 'node_modules', '.bin', 'linked')
- var localModule = resolve(workingDir, 'node_modules', '@test', 'linked')
- try {
- t.ok(fs.statSync(globalBin), 'global bin exists')
- t.is(fs.lstatSync(globalModule).isSymbolicLink(), true, 'global module is link')
- t.ok(fs.statSync(localBin), 'local bin exists')
- t.is(fs.lstatSync(localModule).isSymbolicLink(), true, 'local module is link')
- } catch (ex) {
- t.ifError(ex, 'linking happened')
- }
- if (code !== 0) return t.end()
-
- // and try removing it and make sure that succeeds
- common.npm(
- [
- '--global',
- '--loglevel', 'error',
- 'rm', '@test/linked'
- ],
- EXEC_OPTS,
- function (er, code) {
- if (er) throw er
- t.is(code, 0, 'rm succeeded')
- t.throws(function () { fs.statSync(globalBin) }, 'global bin removed')
- t.throws(function () { fs.statSync(globalModule) }, 'global module removed')
- t.end()
- }
- )
+ return common.npm(['--loglevel', 'error', 'link', toInstall], EXEC_OPTS).spread((code, out) => {
+ t.comment(out)
+ t.is(code, 0, 'link succeeded')
+ var localBin = resolve(workingDir, 'node_modules', '.bin', 'linked')
+ var localModule = resolve(workingDir, 'node_modules', '@test', 'linked')
+ try {
+ t.ok(fs.statSync(globalBin), 'global bin exists')
+ t.is(fs.lstatSync(globalModule).isSymbolicLink(), true, 'global module is link')
+ t.ok(fs.statSync(localBin), 'local bin exists')
+ t.is(fs.lstatSync(localModule).isSymbolicLink(), true, 'local module is link')
+ } catch (ex) {
+ t.ifError(ex, 'linking happened')
}
- )
+ if (code !== 0) throw new Error('aborting')
+
+ // and try removing it and make sure that succeeds
+ return common.npm(['--global', '--loglevel', 'error', 'rm', '@test/linked'], EXEC_OPTS)
+ }).spread((code, out) => {
+ t.comment(out)
+ t.is(code, 0, 'rm succeeded')
+ t.throws(function () { fs.statSync(globalBin) }, 'global bin removed')
+ t.throws(function () { fs.statSync(globalModule) }, 'global module removed')
+ })
})
test('cleanup', function (t) {