Refactoring day1

This commit is contained in:
2020-08-20 20:27:14 +02:00
parent 6aceefeb2f
commit b907489a75
481 changed files with 5321 additions and 5616 deletions

View File

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

View File

@@ -1,6 +1,6 @@
{
"name": "registry-auth-token",
"version": "4.2.0",
"version": "4.1.1",
"description": "Get the auth token set for an npm registry (if any)",
"main": "index.js",
"scripts": {
@@ -45,4 +45,8 @@
"coverage/**"
]
}
}
,"_resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.1.1.tgz"
,"_integrity": "sha512-9bKS7nTl9+/A1s7tnPeGrUpRcVY+LUh7bfFgzpndALdPfXQBfQV77rQVtqgUV3ti4vc/Ik81Ex8UJDWDQ12zQA=="
,"_from": "registry-auth-token@4.1.1"
}

View File

@@ -5,7 +5,6 @@ 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
@@ -472,36 +471,4 @@ 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()
})
})
})
})