Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacing new access token with configured token from npmrc #6847

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,28 @@ class Npm {

get flatOptions () {
const { flat } = this.config
const { list } = this.config

const tokenList = []
// eslint-disable-next-line no-unused-vars
for (const [key, value] of Object.entries(list)) {
if (typeof value === 'object') {
for (const [index, element] of Object.entries(value)) {
if (index.toString().includes('_authToken')) {
tokenList.push(element)
}
}
}
}

const flatKeyPair = Object.keys(flat).find((element) => {
return element.includes('_authToken')
})

if (flatKeyPair && tokenList.length > 1 && flat[flatKeyPair] !== tokenList[1]) {
flat[flatKeyPair] = tokenList[1]
}

flat.nodeVersion = process.version
flat.npmVersion = pkg.version
if (this.command) {
Expand Down
Loading