diff options
author | Robert Kowalski <rok@kowalski.gd> | 2013-05-19 03:15:54 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-05-30 21:17:07 +0400 |
commit | 365cb716404c36dfa4f5074cbc5278c6a5f76880 (patch) | |
tree | d9c333b8c96e5eba5f75278a61f8d7f68ff2113f | |
parent | 5d338d40b04da2cab0d5a4f358551ed83bd7e9cd (diff) |
implement --ignore-shrinkwrap, fixes #3436
-rw-r--r-- | doc/cli/install.md | 3 | ||||
-rw-r--r-- | test/tap/ignore-shrinkwrap.js | 80 | ||||
-rw-r--r-- | test/tap/ignore-shrinkwrap/npm-shrinkwrap.json | 17 | ||||
-rw-r--r-- | test/tap/ignore-shrinkwrap/package.json | 8 |
4 files changed, 108 insertions, 0 deletions
diff --git a/doc/cli/install.md b/doc/cli/install.md index 2f325514a..c4d9ba649 100644 --- a/doc/cli/install.md +++ b/doc/cli/install.md @@ -168,6 +168,9 @@ local space in some cases. The `--no-bin-links` argument will prevent npm from creating symlinks for any binaries the package might contain. +The `--no-shrinkwrap` argument, which will ignore an available +shrinkwrap file and use the package.json instead. + See `npm-config(1)`. Many of the configuration params have some effect on installation, since that's most of what npm does. diff --git a/test/tap/ignore-shrinkwrap.js b/test/tap/ignore-shrinkwrap.js new file mode 100644 index 000000000..b5b89a56c --- /dev/null +++ b/test/tap/ignore-shrinkwrap.js @@ -0,0 +1,80 @@ +var test = require("tap").test +var npm = require("../../") +var pkg = './ignore-shrinkwrap' +var http = require("http") + + +var server, child +var spawn = require("child_process").spawn +var npm = require.resolve("../../bin/npm-cli.js") +var node = process.execPath + +test("ignore-shrinkwrap: using the option", function(t) { + t.plan(1) + server = http.createServer(function (req, res) { + res.setHeader("content-type", "application/javascript") + switch (req.url) { + case "/shrinkwrap.js": + t.fail() + break + case "/package.js": + t.pass("package.json used") + + } + t.end() + this.close() + child.kill() + res.statusCode = 500 + res.end('{"error":"Rocko Artischocko - oh oh oh oh!"}') + }) + server.listen(1337, function() { + child = createChild(true) + }) +}) + +test("ignore-shrinkwrap: NOT using the option", function(t) { + t.plan(1) + server = http.createServer(function (req, res) { + res.setHeader("content-type", "application/javascript") + switch (req.url) { + case "/shrinkwrap.js": + t.pass("shrinkwrap used") + break + case "/package.js": + t.fail() + + } + t.end() + this.close() + child.kill() + res.statusCode = 500 + res.end('{"error":"Rocko Artischocko - oh oh oh oh!"}') + }) + server.listen(1337, function() { + child = createChild(false) + }) +}) + + +function createChild (ignoreShrinkwrap) { + var args + if (ignoreShrinkwrap) { + args = [npm, "install", "--no-shrinkwrap"] + } else { + args = [npm, "install"] + } + + console.log(args) + + return spawn(node, args, { + cwd: pkg, + env: { + npm_config_cache_lock_stale: 1000, + npm_config_cache_lock_wait: 1000, + HOME: process.env.HOME, + Path: process.env.PATH, + PATH: process.env.PATH + } + }) + +} diff --git a/test/tap/ignore-shrinkwrap/npm-shrinkwrap.json b/test/tap/ignore-shrinkwrap/npm-shrinkwrap.json new file mode 100644 index 000000000..b15538018 --- /dev/null +++ b/test/tap/ignore-shrinkwrap/npm-shrinkwrap.json @@ -0,0 +1,17 @@ +{ + "name": "ignore-shrinkwrap", + "version": "0.0.0", + "dependencies": { + "npm-test-ignore-shrinkwrap-file": { + "version": "1.2.3", + "from": "http://localhost:1337/shrinkwrap.js", + "resolved": "http://localhost:1337/shrinkwrap.js", + "dependencies": { + "opener": { + "version": "1.3.0", + "from": "opener@1.3.0" + } + } + } + } +} diff --git a/test/tap/ignore-shrinkwrap/package.json b/test/tap/ignore-shrinkwrap/package.json new file mode 100644 index 000000000..5b9500664 --- /dev/null +++ b/test/tap/ignore-shrinkwrap/package.json @@ -0,0 +1,8 @@ +{ + "author": "Rocko Artischocko", + "name": "ignore-shrinkwrap", + "version": "0.0.0", + "dependencies": { + "npm-test-ignore-shrinkwrap-file": "http://localhost:1337/package.js" + } +} |