This commit is contained in:
2020-08-20 11:44:32 +02:00
parent 4715fc1814
commit 6aceefeb2f
2891 changed files with 11239 additions and 347539 deletions

View File

@@ -5,6 +5,7 @@ var assert = require('assert')
var requireUncached = require('require-uncached')
var npmRcPath = path.join(__dirname, '..', '.npmrc')
var beforeEach = mocha.beforeEach
var afterEach = mocha.afterEach
var describe = mocha.describe
var it = mocha.it
@@ -471,4 +472,36 @@ describe('auth-token', function () {
})
})
})
describe('npmrc file resolution', function () {
let npmRcPath
beforeEach(function () {
process.env.npm_config_userconfig = ''
process.env.NPM_CONFIG_USERCONFIG = ''
})
afterEach(function (done) {
process.env.npm_config_userconfig = ''
process.env.NPM_CONFIG_USERCONFIG = ''
fs.unlink(npmRcPath, function () {
done()
})
})
it('should use npmrc from environment npm_config_userconfig', function (done) {
var content = [
'registry=http://registry.foobar.eu/',
'//registry.foobar.eu/:_authToken=foobar', ''
].join('\n')
npmRcPath = path.join(__dirname, '..', '.npmrc.env')
process.env.NPM_CONFIG_USERCONFIG = npmRcPath
fs.writeFile(npmRcPath, content, function (err) {
var getAuthToken = requireUncached('../index')
assert(!err, err)
assert.deepStrictEqual(getAuthToken(), { token: 'foobar', type: 'Bearer' })
done()
})
})
})
})