summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/shrinkwrap-dev-dependency.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/tap/shrinkwrap-dev-dependency.js')
-rw-r--r--deps/npm/test/tap/shrinkwrap-dev-dependency.js73
1 files changed, 39 insertions, 34 deletions
diff --git a/deps/npm/test/tap/shrinkwrap-dev-dependency.js b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
index 0a239e97ce..3328134629 100644
--- a/deps/npm/test/tap/shrinkwrap-dev-dependency.js
+++ b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
@@ -8,36 +8,13 @@ var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
-var npm = npm = require('../../')
var pkg = path.resolve(__dirname, 'shrinkwrap-dev-dependency')
-test("shrinkwrap doesn't strip out the dependency", function (t) {
- t.plan(1)
-
- mr({port: common.port}, function (er, s) {
- setup(function (err) {
- if (err) return t.fail(err)
-
- npm.install('.', function (err) {
- if (err) return t.fail(err)
-
- npm.commands.shrinkwrap([], true, function (err, results) {
- if (err) return t.fail(err)
-
- t.deepEqual(results, desired)
- s.close()
- t.end()
- })
- })
- })
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
+var opts = [
+ '--cache', path.resolve(pkg, 'cache'),
+ '--registry', common.registry
+]
var desired = {
name: 'npm-test-shrinkwrap-dev-dependency',
@@ -69,20 +46,48 @@ var json = {
}
}
-function setup (cb) {
+function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
process.chdir(pkg)
-
- var opts = {
- cache: path.resolve(pkg, 'cache'),
- registry: common.registry
- }
- npm.load(opts, cb)
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
+
+test('setup', function (t) {
+ setup()
+ t.end()
+})
+
+test("shrinkwrap doesn't strip out the dependency", function (t) {
+ t.plan(3)
+ setup()
+
+ mr({port: common.port}, function (er, s) {
+ common.npm(opts.concat(['install', '.']), {stdio: [0, 'pipe', 2]}, function (err, code) {
+ if (err) throw err
+ if (!t.is(code, 0)) return (s.close(), t.end())
+ common.npm(opts.concat(['shrinkwrap']), {stdio: [0, 2, 2]}, function (err, code) {
+ if (err) throw err
+ t.is(code, 0)
+ try {
+ var results = JSON.parse(fs.readFileSync(path.join(pkg, 'npm-shrinkwrap.json')))
+ } catch (ex) {
+ t.comment(ex)
+ }
+ t.deepEqual(results, desired)
+ s.close()
+ t.end()
+ })
+ })
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})