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:
authorisaacs <i@izs.me>2011-01-29 05:28:08 +0300
committerisaacs <i@izs.me>2011-01-29 05:28:08 +0300
commitb6828d58414b55bab150ce5e0837de04da94fd59 (patch)
treeb6128e288bc2c4d3d5a7692882d82b1d81051471
parente206a4c35f8a272107bfe5a8bc1ca93f7588a96e (diff)
Add --node-version config to override engine checking
Set to null to disable engine checking altogether, or some semver string to use that instead of the actual version.
-rw-r--r--doc/config.md9
-rw-r--r--lib/utils/default-config.js1
-rw-r--r--lib/utils/parse-args.js2
-rw-r--r--lib/utils/read-json.js10
-rw-r--r--man1/config.110
-rw-r--r--man1/get.110
-rw-r--r--man1/set.110
7 files changed, 49 insertions, 3 deletions
diff --git a/doc/config.md b/doc/config.md
index 010691bf7..14621de0c 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -360,3 +360,12 @@ default, `npm install foo` will fetch and install the latest version of
Default: true
Show the package description in npm ls.
+
+## node-version
+
+Default: `process.version` from the node environment
+
+An effective version of node to use when checking for "engines"
+compliance.
+
+Set to null or false to suppress engine checking altogether.
diff --git a/lib/utils/default-config.js b/lib/utils/default-config.js
index 8d43307b2..cd0714a18 100644
--- a/lib/utils/default-config.js
+++ b/lib/utils/default-config.js
@@ -38,6 +38,7 @@ module.exports =
, loglevel : "info"
, manroot : path.join(process.execPath, "..", "..", "share", "man")
, "must-install" : true
+ , "node-version" : process.version
, outfd : stdio.stdoutFD
, proxy : process.env.http_proxy || null
, prune : undefined // if set to boolean false, then that means "never"
diff --git a/lib/utils/parse-args.js b/lib/utils/parse-args.js
index fbd9914b7..d3d769092 100644
--- a/lib/utils/parse-args.js
+++ b/lib/utils/parse-args.js
@@ -33,6 +33,7 @@ exports.types =
, loglevel : ["silent","win","error","warn","info","verbose","silly"]
, manroot : path
, "must-install" : Boolean
+ , "node-version" : String
, outfd : [Number, Stream]
, proxy : url
, prune : Boolean
@@ -71,6 +72,7 @@ exports.shorthands =
, "no-rb" : ["--no-rebuild-bundle"]
, desc : ["--description"]
, "no-desc" : ["--no-description"]
+ , "nv" : "--node-version"
}
diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js
index 22c3054c5..816da1d04 100644
--- a/lib/utils/read-json.js
+++ b/lib/utils/read-json.js
@@ -218,8 +218,9 @@ function testEngine (json) {
} else json.engines = [ json.engines ]
}
- var nodeVer = process.version.replace(/\+$/, '')
+ var nodeVer = npm.config.get("node-version")
, ok = false
+ if (nodeVer) nodeVer = nodeVer.replace(/\+$/, '')
if (Array.isArray(json.engines)) {
// Packages/1.0 commonjs style, with an array.
// hack it to just hang a "node" member with the version range,
@@ -236,10 +237,13 @@ function testEngine (json) {
if (json.engines.node === "") json.engines.node = "*"
if (json.engines.node && null === semver.validRange(json.engines.node)) {
log.warn( json.engines.node
- , "not a valid range. Please see `npm help json`" )
+ , "Invalid range in engines.node. Please see `npm help json`" )
}
- json._engineSupported = semver.satisfies(nodeVer, json.engines.node||"null")
+ if (nodeVer) {
+ json._engineSupported = semver.satisfies( nodeVer
+ , json.engines.node || "null" )
+ }
if (json.engines.hasOwnProperty("npm") && json._engineSupported) {
json._engineSupported = semver.satisfies(npm.version, json.engines.npm)
}
diff --git a/man1/config.1 b/man1/config.1
index adc330b5a..15fe8385a 100644
--- a/man1/config.1
+++ b/man1/config.1
@@ -460,3 +460,13 @@ Default: true
.
.P
Show the package description in npm ls\.
+.
+.SH "node\-version"
+Default: \fBprocess\.version\fR from the node environment
+.
+.P
+An effective version of node to use when checking for "engines"
+compliance\.
+.
+.P
+Set to null or false to suppress engine checking altogether\.
diff --git a/man1/get.1 b/man1/get.1
index adc330b5a..15fe8385a 100644
--- a/man1/get.1
+++ b/man1/get.1
@@ -460,3 +460,13 @@ Default: true
.
.P
Show the package description in npm ls\.
+.
+.SH "node\-version"
+Default: \fBprocess\.version\fR from the node environment
+.
+.P
+An effective version of node to use when checking for "engines"
+compliance\.
+.
+.P
+Set to null or false to suppress engine checking altogether\.
diff --git a/man1/set.1 b/man1/set.1
index adc330b5a..15fe8385a 100644
--- a/man1/set.1
+++ b/man1/set.1
@@ -460,3 +460,13 @@ Default: true
.
.P
Show the package description in npm ls\.
+.
+.SH "node\-version"
+Default: \fBprocess\.version\fR from the node environment
+.
+.P
+An effective version of node to use when checking for "engines"
+compliance\.
+.
+.P
+Set to null or false to suppress engine checking altogether\.