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:
authorRobert Kowalski <rok@kowalski.gd>2013-06-15 03:23:32 +0400
committerisaacs <i@izs.me>2013-10-24 10:57:49 +0400
commita82d6c764075527b8c643229a1745e01e07da0a3 (patch)
tree2b07b07810faa3d0bb4487f70842e54730049efa
parente790ae98a8b52fd6a4e8d70e663bb327466b166c (diff)
let npm.commands.uninstall() return an array of removed items
Fixes #1754
-rw-r--r--lib/unbuild.js5
-rw-r--r--test/tap/uninstall-package.js24
-rw-r--r--test/tap/uninstall-package/package.json9
3 files changed, 37 insertions, 1 deletions
diff --git a/lib/unbuild.js b/lib/unbuild.js
index ec34d5688..57688f069 100644
--- a/lib/unbuild.js
+++ b/lib/unbuild.js
@@ -20,7 +20,10 @@ function unbuild (args, silent, cb) {
asyncMap(args, unbuild_(silent), cb)
}
-function unbuild_ (silent) { return function (folder, cb) {
+function unbuild_ (silent) { return function (folder, cb_) {
+ function cb (er) {
+ cb_(er, path.relative(npm.root, folder))
+ }
folder = path.resolve(folder)
delete build._didBuild[folder]
log.info(folder, "unbuild")
diff --git a/test/tap/uninstall-package.js b/test/tap/uninstall-package.js
new file mode 100644
index 000000000..d6bfa0d8f
--- /dev/null
+++ b/test/tap/uninstall-package.js
@@ -0,0 +1,24 @@
+var test = require("tap").test
+ , npm = require("../../")
+
+test("returns a list of removed items", function (t) {
+ t.plan(1)
+
+ setup(function () {
+ npm.install(".", function (err) {
+ if (err) return t.fail(err)
+ npm.uninstall("once", "ini", "lala", function (err, d) {
+ if (err) return t.fail(err)
+ t.same(d.sort(), ["once", "ini"].sort())
+ t.end()
+ })
+ })
+ })
+})
+
+function setup (cb) {
+ process.chdir(__dirname + "/uninstall-package")
+ npm.load(function () {
+ cb()
+ })
+}
diff --git a/test/tap/uninstall-package/package.json b/test/tap/uninstall-package/package.json
new file mode 100644
index 000000000..e445a1c6d
--- /dev/null
+++ b/test/tap/uninstall-package/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "beep",
+ "version": "0.0.0",
+ "main": "index.js",
+ "dependencies": {
+ "once": "*",
+ "ini": "*"
+ }
+}