summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap/shrinkwrap-dev-dependency.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-02-14 10:08:15 -0800
committerisaacs <i@izs.me>2014-02-14 10:08:15 -0800
commit89caae26ba61e2a6db3c76b6deec831444959a13 (patch)
tree1b9696e27c802a492f84ca8716a56ba213835990 /deps/npm/test/tap/shrinkwrap-dev-dependency.js
parent55543d3c45777e2867b86109454e1686e9956c5f (diff)
downloadnode-npm-v1.4.2.tar.gz
npm: upgrade to v1.4.2npm-v1.4.2
Diffstat (limited to 'deps/npm/test/tap/shrinkwrap-dev-dependency.js')
-rw-r--r--deps/npm/test/tap/shrinkwrap-dev-dependency.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/deps/npm/test/tap/shrinkwrap-dev-dependency.js b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
new file mode 100644
index 000000000..fc606cf40
--- /dev/null
+++ b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
@@ -0,0 +1,66 @@
+var npm = npm = require("../../")
+var test = require("tap").test
+var path = require("path")
+var fs = require("fs")
+var osenv = require("osenv")
+var rimraf = require("rimraf")
+var mr = require("npm-registry-mock")
+var common = require("../common-tap.js")
+
+var pkg = path.resolve(__dirname, "shrinkwrap-dev-dependency")
+var desiredResultsPath = path.resolve(pkg, "desired-shrinkwrap-results.json")
+
+test("shrinkwrap doesn't strip out the dependency", function (t) {
+ t.plan(1)
+
+ mr(common.port, function (s) {
+ setup({ production: true }, 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)
+
+ fs.readFile(desiredResultsPath, function (err, desired) {
+ if (err) return t.fail(err)
+
+ t.deepEqual(results, JSON.parse(desired))
+ s.close()
+ t.end()
+ })
+ })
+ })
+ })
+ })
+})
+
+test("cleanup", function (t) {
+ cleanup()
+ t.end()
+})
+
+
+function setup (opts, cb) {
+ cleanup()
+ process.chdir(pkg)
+
+ var allOpts = {
+ cache: path.resolve(pkg, "cache"),
+ registry: common.registry
+ }
+
+ for (var key in opts) {
+ allOpts[key] = opts[key]
+ }
+
+ npm.load(allOpts, cb)
+}
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(path.resolve(pkg, "node_modules"))
+ rimraf.sync(path.resolve(pkg, "cache"))
+ rimraf.sync(path.resolve(pkg, "npm-shrinkwrap.json"))
+}