diff options
Diffstat (limited to 'deps/npm/test/tap/install-at-sub-path-locally.js')
-rw-r--r-- | deps/npm/test/tap/install-at-sub-path-locally.js | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/deps/npm/test/tap/install-at-sub-path-locally.js b/deps/npm/test/tap/install-at-sub-path-locally.js index 08b64746af..931d29bbd2 100644 --- a/deps/npm/test/tap/install-at-sub-path-locally.js +++ b/deps/npm/test/tap/install-at-sub-path-locally.js @@ -2,13 +2,11 @@ var fs = require('graceful-fs') var path = require('path') var mkdirp = require('mkdirp') -var osenv = require('osenv') -var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var pkg = common.pkg +var pkg = path.resolve(common.pkg, 'package') var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] } @@ -20,12 +18,17 @@ var json = { var target = '../package@1.2.3' test('setup', function (t) { - cleanup() + var root = path.resolve(pkg, target) + mkdirp.sync(root) + fs.writeFileSync( + path.join(root, 'package.json'), + JSON.stringify(json, null, 2) + ) + mkdirp.sync(path.resolve(pkg, 'node_modules')) t.end() }) test('\'npm install ../package@1.2.3\' should install local pkg from sub path', function (t) { - setup() common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) { if (err) throw err var p = path.resolve(pkg, 'node_modules/install-at-sub-path-locally-mock/package.json') @@ -44,26 +47,3 @@ test('\'running npm install ../package@1.2.3\' should not break on sub path re-i t.end() }) }) - -test('cleanup', function (t) { - cleanup() - t.end() -}) - -function cleanup () { - process.chdir(osenv.tmpdir()) - rimraf.sync(pkg) - rimraf.sync(path.resolve(pkg, target)) -} - -function setup () { - cleanup() - var root = path.resolve(pkg, target) - mkdirp.sync(root) - fs.writeFileSync( - path.join(root, 'package.json'), - JSON.stringify(json, null, 2) - ) - mkdirp.sync(path.resolve(pkg, 'node_modules')) - process.chdir(pkg) -} |