Comparing version 0.0.1 to 0.0.2
@@ -139,14 +139,2 @@ | ||
this.root = configDefs.defaults | ||
// whenever we save, make sure the permissions and such are good | ||
this.on('save', function () { | ||
function noop () {} | ||
if (this.sources.user) { | ||
if (myUid && myGid) | ||
fs.chown(this.sources.user.path, +myUid, +myGid, noop) | ||
fs.chmod(this.sources.user.path, 0666, noop) | ||
} | ||
if (this.sources.global) | ||
fs.chmod(this.sources.global.path, 0600, noop) | ||
}) | ||
} | ||
@@ -156,5 +144,4 @@ | ||
var target = this.sources[where] | ||
if (!target || !(target.path || target.source) || !target.data) { | ||
if (!target || !(target.path || target.source) || !target.data) | ||
return this.emit('error', new Error('bad save target: '+where)) | ||
} | ||
@@ -169,4 +156,19 @@ if (target.source) { | ||
var data = ini.stringify(target.data) | ||
var data = target.data | ||
if (typeof data._password === 'string' && | ||
typeof data.username === 'string') { | ||
var auth = data.username + ':' + data._password | ||
data = Object.keys(data).reduce(function (c, k) { | ||
if (k === 'username' || k === '_password') | ||
return c | ||
c[k] = data[k] | ||
return c | ||
}, { _auth: new Buffer(auth, 'utf8').toString('base64') }) | ||
delete data.username | ||
delete data._password | ||
} | ||
data = ini.stringify(data) | ||
then = then.bind(this) | ||
@@ -233,2 +235,9 @@ done = done.bind(this) | ||
}) | ||
if (Object.prototype.hasOwnProperty.call(data, '_auth')) { | ||
var auth = new Buffer(data._auth, 'base64').toString('utf8').split(':') | ||
var username = auth.shift() | ||
var password = auth.join(':') | ||
data.username = username | ||
data._password = password | ||
} | ||
return CC.prototype.add.call(this, data, marker) | ||
@@ -235,0 +244,0 @@ } |
{ | ||
"name": "npmconf", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "The config thing npm uses", | ||
@@ -5,0 +5,0 @@ "main": "npmconf.js", |
@@ -22,2 +22,4 @@ var test = require('tap').test | ||
'tmp': process.env.HOME + '/.tmp', | ||
username : "username", | ||
_password : "password", | ||
_token: | ||
@@ -24,0 +26,0 @@ { AuthSession: 'yabba-dabba-doodle', |
@@ -22,2 +22,4 @@ var test = require('tap').test | ||
'tmp': process.env.HOME + '/.tmp', | ||
username : "username", | ||
_password : "password", | ||
_token: | ||
@@ -24,0 +26,0 @@ { AuthSession: 'yabba-dabba-doodle', |
@@ -6,3 +6,3 @@ var test = require('tap').test | ||
var ini = require('ini') | ||
var expect = | ||
var expectConf = | ||
[ 'globalconfig = /Users/isaacs/dev/js/npmconf/test/fixtures/globalconfig', | ||
@@ -22,2 +22,4 @@ 'email = i@izs.me', | ||
'strict-ssl = false', | ||
'username = username', | ||
'_password = password', | ||
'', | ||
@@ -31,2 +33,25 @@ '[_token]', | ||
'' ].join('\n') | ||
var expectFile = | ||
[ 'globalconfig = /Users/isaacs/dev/js/npmconf/test/fixtures/globalconfig', | ||
'email = i@izs.me', | ||
'env-thing = asdf', | ||
'init.author.name = Isaac Z. Schlueter', | ||
'init.author.email = i@izs.me', | ||
'init.author.url = http://blog.izs.me/', | ||
'proprietary-attribs = false', | ||
'npm:publishtest = true', | ||
'_npmjs.org:couch = https://admin:password@localhost:5984/registry', | ||
'_auth = dXNlcm5hbWU6cGFzc3dvcmQ=', | ||
'npm-www:nocache = 1', | ||
'sign-git-tag = false', | ||
'message = v%s', | ||
'strict-ssl = false', | ||
'', | ||
'[_token]', | ||
'AuthSession = yabba-dabba-doodle', | ||
'version = 1', | ||
'expires = 1345001053415', | ||
'path = /', | ||
'httponly = true', | ||
'' ].join('\n') | ||
@@ -41,3 +66,4 @@ test('saving configs', function (t) { | ||
var foundConf = ini.stringify(conf.sources.user.data) | ||
t.equal(foundConf, expect) | ||
t.same(ini.parse(foundConf), ini.parse(expectConf)) | ||
fs.unlinkSync(common.userconfig) | ||
conf.save('user', function (er) { | ||
@@ -47,3 +73,3 @@ if (er) | ||
var uc = fs.readFileSync(conf.get('userconfig'), 'utf8') | ||
t.equal(uc, expect) | ||
t.same(ini.parse(uc), ini.parse(expectFile)) | ||
t.end() | ||
@@ -50,0 +76,0 @@ }) |
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
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
27388
809