summaryrefslogtreecommitdiff
path: root/deps/npm/lib/config
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-01-23 06:56:30 -0800
committerBen Noordhuis <info@bnoordhuis.nl>2015-01-23 23:19:27 +0100
commitf5b35dbda45c466eda888a4451591c66e8671faf (patch)
treefe89dd3e105a3693bd0776c678813dadae21065d /deps/npm/lib/config
parentf3fed5193caaac151acd555a7523068ee269801c (diff)
downloadnode-new-f5b35dbda45c466eda888a4451591c66e8671faf.tar.gz
deps: upgrade npm to 2.3.0
* Windows improvements: no more uid is undefined errors, use `%COMSPEC%` when set in preference to hardcoded `cmd`, improved handling of Git remotes. * Add caching based on Last-Modified / If-Modified-Since headers in addition to Etag-based cache validation. PR-URL: https://github.com/iojs/io.js/pull/573 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/npm/lib/config')
-rw-r--r--deps/npm/lib/config/core.js12
-rw-r--r--deps/npm/lib/config/defaults.js28
2 files changed, 18 insertions, 22 deletions
diff --git a/deps/npm/lib/config/core.js b/deps/npm/lib/config/core.js
index 6c6112532f..59f7cf5568 100644
--- a/deps/npm/lib/config/core.js
+++ b/deps/npm/lib/config/core.js
@@ -8,8 +8,9 @@ var fs = require("fs")
var path = require("path")
var nopt = require("nopt")
var ini = require("ini")
-var Octal = configDefs.Octal
+var Umask = configDefs.Umask
var mkdirp = require("mkdirp")
+var umask = require("../utils/umask")
exports.load = load
exports.Conf = Conf
@@ -362,8 +363,8 @@ function parseField (f, k) {
var isPath = -1 !== typeList.indexOf(path)
var isBool = -1 !== typeList.indexOf(Boolean)
var isString = -1 !== typeList.indexOf(String)
- var isOctal = -1 !== typeList.indexOf(Octal)
- var isNumber = isOctal || (-1 !== typeList.indexOf(Number))
+ var isUmask = -1 !== typeList.indexOf(Umask)
+ var isNumber = -1 !== typeList.indexOf(Number)
f = (""+f).trim()
@@ -396,8 +397,11 @@ function parseField (f, k) {
f = path.resolve(f)
}
+ if (isUmask)
+ f = umask.fromString(f)
+
if (isNumber && !isNaN(f))
- f = isOctal ? parseInt(f, 8) : +f
+ f = +f
return f
}
diff --git a/deps/npm/lib/config/defaults.js b/deps/npm/lib/config/defaults.js
index febd1049ed..3d99ab86fa 100644
--- a/deps/npm/lib/config/defaults.js
+++ b/deps/npm/lib/config/defaults.js
@@ -9,6 +9,7 @@ var path = require("path")
, nopt = require("nopt")
, os = require("os")
, osenv = require("osenv")
+ , umask = require("../utils/umask")
var log
try {
@@ -20,19 +21,10 @@ try {
} }
}
-exports.Octal = Octal
-function Octal () {}
-function validateOctal (data, k, val) {
- // must be either an integer or an octal string.
- if (typeof val === "number") {
- data[k] = val
- return true
- }
-
- if (typeof val === "string") {
- if (val.charAt(0) !== "0" || isNaN(val)) return false
- data[k] = parseInt(val, 8).toString(8)
- }
+exports.Umask = Umask
+function Umask () {}
+function validateUmask (data, k, val) {
+ return umask.validate (data, k, val)
}
function validateSemver (data, k, val) {
@@ -52,8 +44,8 @@ function validateStream (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.typeDefs.Umask = { type: Umask, validate: validateUmask }
// Don't let --tag=1.2.3 ever be a thing
var tag = {}
@@ -71,8 +63,8 @@ nopt.invalidHandler = function (k, val, type) {
case tag:
log.warn("invalid config", "Tag must not be a SemVer range")
break
- case Octal:
- log.warn("invalid config", "Must be octal number, starting with 0")
+ case Umask:
+ log.warn("invalid config", "Must be umask, octal number in range 0000..0777")
break
case url:
log.warn("invalid config", "Must be a full url with 'http://'")
@@ -224,7 +216,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
, usage : false
, user : process.platform === "win32" ? 0 : "nobody"
, userconfig : path.resolve(home, ".npmrc")
- , umask: process.umask ? process.umask() : parseInt("022", 8)
+ , umask: process.umask ? process.umask() : umask.fromString("022")
, version : false
, versions : false
, viewer: process.platform === "win32" ? "browser" : "man"
@@ -322,7 +314,7 @@ exports.types =
, usage : Boolean
, user : [Number, String]
, userconfig : path
- , umask: Octal
+ , umask: Umask
, version : Boolean
, versions : Boolean
, viewer: String