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

@@ -2,6 +2,12 @@
All notable changes will be documented in this file.
## [4.2.0] - 2020-07-13
### Changes
- Add support for `NPM_CONFIG_USERCONFIG` environment variable (Ben Sorohan)
## [4.1.0] - 2020-01-17
### Changes

View File

@@ -21,7 +21,9 @@ module.exports = function () {
options = arguments[0]
}
options = options || {}
options.npmrc = options.npmrc || require('rc')('npm', { registry: 'https://registry.npmjs.org/' })
options.npmrc = options.npmrc || require('rc')('npm', { registry: 'https://registry.npmjs.org/' }, {
config: process.env.npm_config_userconfig || process.env.NPM_CONFIG_USERCONFIG
})
checkUrl = checkUrl || options.npmrc.registry
return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc)
}

View File

@@ -1,50 +1,20 @@
{
"_from": "registry-auth-token@^4.0.0",
"_id": "registry-auth-token@4.1.1",
"_inBundle": false,
"_integrity": "sha512-9bKS7nTl9+/A1s7tnPeGrUpRcVY+LUh7bfFgzpndALdPfXQBfQV77rQVtqgUV3ti4vc/Ik81Ex8UJDWDQ12zQA==",
"_location": "/registry-auth-token",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "registry-auth-token@^4.0.0",
"name": "registry-auth-token",
"escapedName": "registry-auth-token",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/package-json"
],
"_resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.1.1.tgz",
"_shasum": "40a33be1e82539460f94328b0f7f0f84c16d9479",
"_spec": "registry-auth-token@^4.0.0",
"_where": "D:\\WORK\\Menui\\menui_backend\\node_modules\\package-json",
"author": {
"name": "Espen Hovlandsdal",
"email": "espen@hovlandsdal.com"
},
"bugs": {
"url": "https://github.com/rexxars/registry-auth-token/issues"
},
"bundleDependencies": false,
"dependencies": {
"rc": "^1.2.8"
},
"deprecated": false,
"name": "registry-auth-token",
"version": "4.2.0",
"description": "Get the auth token set for an npm registry (if any)",
"devDependencies": {
"istanbul": "^0.4.2",
"mocha": "^6.1.4",
"require-uncached": "^1.0.2",
"standard": "^12.0.1"
"main": "index.js",
"scripts": {
"test": "mocha",
"posttest": "standard",
"coverage": "istanbul cover _mocha"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/rexxars/registry-auth-token.git"
},
"engines": {
"node": ">=6.0.0"
},
"homepage": "https://github.com/rexxars/registry-auth-token#readme",
"keywords": [
"npm",
"conf",
@@ -55,22 +25,24 @@
"token",
"authtoken"
],
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
"license": "MIT",
"main": "index.js",
"name": "registry-auth-token",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/rexxars/registry-auth-token.git"
"bugs": {
"url": "https://github.com/rexxars/registry-auth-token/issues"
},
"scripts": {
"coverage": "istanbul cover _mocha",
"posttest": "standard",
"test": "mocha"
"homepage": "https://github.com/rexxars/registry-auth-token#readme",
"dependencies": {
"rc": "^1.2.8"
},
"devDependencies": {
"istanbul": "^0.4.2",
"mocha": "^6.1.4",
"require-uncached": "^1.0.2",
"standard": "^12.0.1"
},
"standard": {
"ignore": [
"coverage/**"
]
},
"version": "4.1.1"
}
}

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()
})
})
})
})