Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-05-25 14:57:53 +0300
committerRebecca Turner <me@re-becca.org>2017-05-26 04:55:32 +0300
commit80202cd4d6b7dd4f136d93a7000eeb8fd1456aa3 (patch)
tree22fb13f743064482c040a3736571d717672f6af2 /test
parent3ada941d6eb94b3b0920d8b6d6db7d1bdcfd8876 (diff)
test: gently-rm-linked-module: modernize test
Diffstat (limited to 'test')
-rw-r--r--test/tap/gently-rm-linked-module.js66
1 files changed, 24 insertions, 42 deletions
diff --git a/test/tap/gently-rm-linked-module.js b/test/tap/gently-rm-linked-module.js
index aeae71eee..7d5c4905e 100644
--- a/test/tap/gently-rm-linked-module.js
+++ b/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, 1, 2]
}
test('setup', function (t) {
@@ -58,48 +59,29 @@ test('setup', function (t) {
test('install and link', function (t) {
// 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) => {
+ 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) 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) => {
+ 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) {