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
diff options
context:
space:
mode:
authorDav Glass <davglass@gmail.com>2014-02-15 06:52:00 +0400
committerisaacs <i@izs.me>2014-02-16 00:40:41 +0400
commitacc4d023c57d07704b20a0955e4bf10ee91bdc83 (patch)
tree22d4baddf13c604f8c7d3d336460d5966ec9e638
parent8a26f6ff7e9769985f74b60eed54e488a4d4a804 (diff)
prune: Added back --production support
fixes #4509 Test by @isaacs
-rw-r--r--lib/prune.js2
-rw-r--r--test/tap/prune.js107
-rw-r--r--test/tap/prune/package.json13
3 files changed, 121 insertions, 1 deletions
diff --git a/lib/prune.js b/lib/prune.js
index b4836cc6d..8fa3e5d50 100644
--- a/lib/prune.js
+++ b/lib/prune.js
@@ -21,7 +21,7 @@ function prune (args, cb) {
})
function next() {
- var opt = { depth: npm.config.get("depth") }
+ var opt = { depth: npm.config.get("depth"), dev: npm.config.get("production") }
readInstalled(npm.prefix, opt, function (er, data) {
if (er) return cb(er)
prune_(args, data, cb)
diff --git a/test/tap/prune.js b/test/tap/prune.js
new file mode 100644
index 000000000..acfdc42e3
--- /dev/null
+++ b/test/tap/prune.js
@@ -0,0 +1,107 @@
+var test = require("tap").test
+var fs = require("fs")
+var node = process.execPath
+var npm = require.resolve("../../bin/npm-cli.js")
+var rimraf = require("rimraf")
+var mr = require("npm-registry-mock")
+var common = require("../common-tap.js")
+var spawn = require("child_process").spawn
+
+var pkg = __dirname + "/prune"
+
+var server
+
+test("reg mock", function (t) {
+ mr(common.port, function (s) {
+ server = s
+ t.pass("registry mock started")
+ t.end()
+ })
+})
+
+test("npm install", function (t) {
+ var c = spawn(node, [
+ npm, "install",
+ "--registry=" + common.registry,
+ "--loglevel=silent",
+ "--production=false"
+ ], { cwd: pkg })
+ c.stderr.on("data", function(d) {
+ t.fail("Should not get data on stderr: " + d)
+ })
+ c.on("close", function(code) {
+ t.notOk(code, "exit ok")
+ t.end()
+ })
+})
+
+test("npm install test-package", function (t) {
+ var c = spawn(node, [
+ npm, "install", "test-package",
+ "--registry=" + common.registry,
+ "--loglevel=silent",
+ "--production=false"
+ ], { cwd: pkg })
+ c.stderr.on("data", function(d) {
+ t.fail("Should not get data on stderr: " + d)
+ })
+ c.on("close", function(code) {
+ t.notOk(code, "exit ok")
+ t.end()
+ })
+})
+
+test("verify installs", function (t) {
+ var dirs = fs.readdirSync(pkg + "/node_modules").sort()
+ t.same(dirs, [ "test-package", "mkdirp", "underscore" ].sort())
+ t.end()
+})
+
+test("npm prune", function (t) {
+ var c = spawn(node, [
+ npm, "prune",
+ "--loglevel=silent",
+ "--production=false"
+ ], { cwd: pkg })
+ c.stderr.on("data", function(d) {
+ t.fail("Should not get data on stderr: " + d)
+ })
+ c.on("close", function(code) {
+ t.notOk(code, "exit ok")
+ t.end()
+ })
+})
+
+test("verify installs", function (t) {
+ var dirs = fs.readdirSync(pkg + "/node_modules").sort()
+ t.same(dirs, [ "mkdirp", "underscore" ])
+ t.end()
+})
+
+test("npm prune", function (t) {
+ var c = spawn(node, [
+ npm, "prune",
+ "--loglevel=silent",
+ "--production"
+ ], { cwd: pkg })
+ c.stderr.on("data", function(d) {
+ t.fail("Should not get data on stderr: " + d)
+ })
+ c.on("close", function(code) {
+ t.notOk(code, "exit ok")
+ t.end()
+ })
+})
+
+test("verify installs", function (t) {
+ var dirs = fs.readdirSync(pkg + "/node_modules").sort()
+ t.same(dirs, [ "underscore" ])
+ t.end()
+})
+
+test("cleanup", function (t) {
+ server.close()
+ rimraf.sync(pkg + "/node_modules")
+ t.pass("cleaned up")
+ t.end()
+})
diff --git a/test/tap/prune/package.json b/test/tap/prune/package.json
new file mode 100644
index 000000000..641ab6580
--- /dev/null
+++ b/test/tap/prune/package.json
@@ -0,0 +1,13 @@
+{
+ "name": "bla",
+ "description": "fixture",
+ "version": "0.0.1",
+ "main": "index.js",
+ "dependencies": {
+ "underscore": "1.3.1"
+ },
+ "devDependencies": {
+ "mkdirp": "*"
+ },
+ "repository": "git://github.com/robertkowalski/bogusfixture"
+}