Comparing version 1.1.1 to 1.1.2
module.exports = loadPrefix | ||
var findPrefix = require("./find-prefix.js") | ||
var mkdirp = require("mkdirp") | ||
var path = require('path') | ||
@@ -11,11 +10,18 @@ | ||
Object.defineProperty(this, "prefix", | ||
{ get : function () { | ||
{ set : function (prefix) { | ||
var g = this.get("global") | ||
this[g ? 'globalPrefix' : 'localPrefix'] = prefix | ||
}.bind(this) | ||
, get : function () { | ||
var g = this.get("global") | ||
return g ? this.globalPrefix : this.localPrefix | ||
}.bind(this) | ||
, enmerable : true | ||
, enumerable : true | ||
}) | ||
Object.defineProperty(this, "globalPrefix", | ||
{ get : function () { | ||
{ set : function (prefix) { | ||
this.set('prefix', prefix) | ||
}.bind(this) | ||
, get : function () { | ||
return path.resolve(this.get("prefix")) | ||
@@ -28,3 +34,4 @@ }.bind(this) | ||
Object.defineProperty(this, "localPrefix", | ||
{ get : function () { return p } | ||
{ set : function (prefix) { p = prefix }, | ||
get : function () { return p } | ||
, enumerable: true }) | ||
@@ -31,0 +38,0 @@ |
@@ -277,5 +277,8 @@ | ||
var mode = where === 'user' ? 0600 : 0666 | ||
if (!data.trim()) | ||
fs.unlink(target.path, done) | ||
else { | ||
if (!data.trim()) { | ||
fs.unlink(target.path, function (er) { | ||
// ignore the possible error (e.g. the file doesn't exist) | ||
done(null) | ||
}) | ||
} else { | ||
mkdirp(path.dirname(target.path), function (er) { | ||
@@ -353,3 +356,3 @@ if (er) | ||
Object.keys(env) | ||
.filter(function (k) { return k.match(/^npm_config_[^_]/i) }) | ||
.filter(function (k) { return k.match(/^npm_config_/i) }) | ||
.forEach(function (k) { | ||
@@ -359,5 +362,7 @@ if (!env[k]) | ||
conf[k.replace(/^npm_config_/i, '') | ||
.toLowerCase() | ||
.replace(/_/g, '-')] = env[k] | ||
// leave first char untouched, even if | ||
// it is a "_" - convert all other to "-" | ||
var p = k.replace(/^npm_config_/, '') | ||
.replace(/(?!^)_/g, '-') | ||
conf[p] = env[k] | ||
}) | ||
@@ -364,0 +369,0 @@ return CC.prototype.addEnv.call(this, '', conf, 'env') |
{ | ||
"name": "npmconf", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "The config thing npm uses", | ||
@@ -5,0 +5,0 @@ "main": "npmconf.js", |
@@ -17,3 +17,16 @@ var path = require('path') | ||
process.env.random_env_var = 'asdf' | ||
process.env.npm_config__underbar_env_thing = 'underful' | ||
exports.envData = { | ||
userconfig: exports.userconfig, | ||
'_underbar-env-thing': 'underful', | ||
'other-env-thing': '1000' | ||
} | ||
exports.envDataFix = { | ||
userconfig: exports.userconfig, | ||
'_underbar-env-thing': 'underful', | ||
'other-env-thing': 1000, | ||
} | ||
if (module === require.main) { | ||
@@ -20,0 +33,0 @@ // set the globalconfig in the userconfig |
@@ -34,4 +34,4 @@ var test = require('tap').test | ||
var envData = { userconfig: common.userconfig, 'other-env-thing': '1000' } | ||
var envDataFix = { userconfig: common.userconfig, 'other-env-thing': 1000 } | ||
var envData = common.envData | ||
var envDataFix = common.envDataFix | ||
@@ -38,0 +38,0 @@ var gcData = { 'package-config:foo': 'boo' } |
@@ -32,4 +32,4 @@ var test = require('tap').test | ||
var envData = { userconfig: common.userconfig, 'other-env-thing': '1000' } | ||
var envDataFix = { userconfig: common.userconfig, 'other-env-thing': 1000 } | ||
var envData = common.envData | ||
var envDataFix = common.envDataFix | ||
@@ -36,0 +36,0 @@ var gcData = { 'package-config:foo': 'boo' } |
@@ -36,4 +36,4 @@ var test = require('tap').test | ||
var envData = { userconfig: common.userconfig, 'other-env-thing': '1000' } | ||
var envDataFix = { userconfig: common.userconfig, 'other-env-thing': 1000 } | ||
var envData = common.envData | ||
var envDataFix = common.envDataFix | ||
@@ -40,0 +40,0 @@ var gcData = { 'package-config:foo': 'boo' } |
@@ -75,1 +75,11 @@ var test = require('tap').test | ||
test('setting prefix', function (t) { | ||
npmconf.load(function (er, conf) { | ||
if (er) | ||
throw er | ||
conf.prefix = 'newvalue' | ||
t.same(conf.prefix, 'newvalue'); | ||
t.end(); | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41595
1198
41