mirror of
https://github.com/zhigang1992/npm.git
synced 2026-06-04 06:39:10 +08:00
logstream option to replace removed logfd
This commit is contained in:
@@ -427,6 +427,18 @@ What level of logs to report. On failure, *all* logs are written to
|
||||
Any logs of a higher level than the setting are shown.
|
||||
The default is "http", which shows http, warn, and error output.
|
||||
|
||||
### logstream
|
||||
|
||||
* Default: process.stderr
|
||||
* Type: Stream
|
||||
|
||||
This is the stream that is passed to the
|
||||
[npmlog](https://github.com/isaacs/npmlog) module at run time.
|
||||
|
||||
It cannot be set from the command line, but if you are using npm
|
||||
programmatically, you may wish to send logs to somewhere other than
|
||||
stderr.
|
||||
|
||||
### long
|
||||
|
||||
* Default: false
|
||||
|
||||
@@ -263,6 +263,7 @@ function load (npm, conf, cb) {
|
||||
ini.resolveConfigs(conf, function (er) {
|
||||
log.level = npm.config.get("loglevel")
|
||||
log.heading = "npm"
|
||||
log.stream = npm.config.get("logstream")
|
||||
switch (npm.config.get("color")) {
|
||||
case "always": log.enableColor(); break
|
||||
case false: log.disableColor(); break
|
||||
|
||||
@@ -28,8 +28,14 @@ function validateSemver (data, k, val) {
|
||||
data[k] = semver.valid(val)
|
||||
}
|
||||
|
||||
function validateStream (data, k, val) {
|
||||
if (!(val instanceof Stream)) return false
|
||||
data[k] = val
|
||||
}
|
||||
|
||||
nopt.typeDefs.semver = { type: semver, validate: validateSemver }
|
||||
nopt.typeDefs.Octal = { type: Octal, validate: validateOctal }
|
||||
nopt.typeDefs.Stream = { type: Stream, validate: validateStream }
|
||||
|
||||
nopt.invalidHandler = function (k, val, type, data) {
|
||||
log.warn("invalid config", k + "=" + JSON.stringify(val))
|
||||
@@ -52,6 +58,9 @@ nopt.invalidHandler = function (k, val, type, data) {
|
||||
case Number:
|
||||
log.warn("invalid config", "Must be a numeric value")
|
||||
break
|
||||
case Stream:
|
||||
log.warn("invalid config", "Must be an instance of the Stream class")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +150,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
|
||||
, json: false
|
||||
, link: false
|
||||
, loglevel : "http"
|
||||
, logstream : process.stderr
|
||||
, long : false
|
||||
, message : "%s"
|
||||
, "node-version" : process.version
|
||||
@@ -222,6 +232,7 @@ exports.types =
|
||||
, json: Boolean
|
||||
, link: Boolean
|
||||
, loglevel : ["silent","win","error","warn","http","info","verbose","silly"]
|
||||
, logstream : Stream
|
||||
, long : Boolean
|
||||
, message: String
|
||||
, "node-version" : [null, semver]
|
||||
|
||||
@@ -10,6 +10,7 @@ var log = require("npmlog")
|
||||
, chain = require("slide").chain
|
||||
, constants = require("constants")
|
||||
, output = require("./output.js")
|
||||
, Stream = require("stream").Stream
|
||||
, PATH = "PATH"
|
||||
|
||||
// windows calls it's path "Path" usually, but this is not guaranteed.
|
||||
@@ -260,6 +261,7 @@ function makeEnv (data, prefix, env) {
|
||||
return
|
||||
}
|
||||
var value = ini.get(i)
|
||||
if (value instanceof Stream) return
|
||||
if (!value) value = ""
|
||||
else if (typeof value !== "string") value = JSON.stringify(value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user