mirror of
https://github.com/zhigang1992/npm.git
synced 2026-01-12 22:49:19 +08:00
Put npm-debug.log file in a consistent place
This commit is contained in:
@@ -9,7 +9,12 @@ var cbCalled = false
|
||||
, path = require("path")
|
||||
, wroteLogFile = false
|
||||
, exitCode = 0
|
||||
, debugFile
|
||||
|
||||
function getDebugFile() {
|
||||
if (debugFile) return debugFile
|
||||
return debugFile = path.resolve(npm.cache, "npm-debug.log")
|
||||
}
|
||||
|
||||
process.on("exit", function (code) {
|
||||
// console.error("exit", code)
|
||||
@@ -24,7 +29,7 @@ process.on("exit", function (code) {
|
||||
if (wroteLogFile) {
|
||||
log.error("", [""
|
||||
,"Additional logging details can be found in:"
|
||||
," " + path.resolve("npm-debug.log")
|
||||
," " + getDebugFile()
|
||||
].join("\n"))
|
||||
wroteLogFile = false
|
||||
}
|
||||
@@ -51,7 +56,7 @@ function exit (code, noLog) {
|
||||
if (log.level === "silent") noLog = true
|
||||
|
||||
if (code && !noLog) writeLogFile(reallyExit)
|
||||
else rm("npm-debug.log", function () { rm(npm.tmp, reallyExit) })
|
||||
else rm(getDebugFile(), function () { rm(npm.tmp, reallyExit) })
|
||||
|
||||
function reallyExit() {
|
||||
// truncate once it's been written.
|
||||
@@ -322,7 +327,7 @@ function writeLogFile (cb) {
|
||||
wroteLogFile = true
|
||||
|
||||
var fs = require("graceful-fs")
|
||||
, fstr = fs.createWriteStream("npm-debug.log")
|
||||
, fstr = fs.createWriteStream(getDebugFile())
|
||||
, util = require("util")
|
||||
, os = require("os")
|
||||
, out = ""
|
||||
|
||||
Reference in New Issue
Block a user