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:
-rwxr-xr-xcli.js9
-rwxr-xr-xnpm.js20
2 files changed, 4 insertions, 25 deletions
diff --git a/cli.js b/cli.js
index 50127442b..207589d6f 100755
--- a/cli.js
+++ b/cli.js
@@ -11,6 +11,7 @@ var fs = require("fs")
, sys = require("sys")
, npm = require("./npm")
, ini = require("./lib/utils/ini")
+ , rm = require("./lib/utils/rm-rf")
// supported commands.
, argv = process.argv.slice(2)
@@ -85,14 +86,12 @@ function errorHandler (er) {
if (!er) {
itWorked = true
log("ok")
- return
+ return rm(npm.tmp, function (er) { process.exit(0) })
}
- sys.error("")
- log(er, "!")
- sys.error("")
+ log.error(er, "!")
log("try running: 'npm help "+command+"'", "failure")
log("Report this *entire* log at <http://github.com/isaacs/npm/issues>", "failure")
log("or email it to <npm-@googlegroups.com>", "failure")
- process.exit(1)
+ rm(npm.tmp, function (er) { process.exit(1) })
}
diff --git a/npm.js b/npm.js
index 47c1d2ee9..326ddcd68 100755
--- a/npm.js
+++ b/npm.js
@@ -96,23 +96,3 @@ Object.defineProperty(npm, "tmp",
{ get : function () { return path.join(npm.root, ".npm", ".tmp") }
, enumerable : true
})
-
-
-process.on("exit", function () {
- var tmp = npm.tmp
- try {
- var files = fs.readdirSync(tmp)
- } catch (er) {
- if (er.message.indexOf("ENOENT") === 0) return
- return log(er, "Couldn't clean up tmp folder")
- }
- files.forEach(function (f) {
- try { fs.unlinkSync(tmp + "/" +f) }
- catch (er) {
- log("Couldn't remove "+tmp+"/"+f, "tmp cleanup error")
- log(er, "tmp cleanup error")
- log("No big deal, just remove it manually.", "tmp cleanup error")
- log(" rm "+tmp+"/"+f, "tmp cleanup error")
- }
- })
-})