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

fix: repair config items using raw values when possible #6093

Merged
merged 1 commit into from Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions workspaces/config/lib/index.js
Expand Up @@ -482,8 +482,9 @@ class Config {
if (problem.action === 'delete') {
this.delete(problem.key, problem.where)
} else if (problem.action === 'rename') {
const old = this.get(problem.from, problem.where)
this.set(problem.to, old, problem.where)
const raw = this.data.get(problem.where).raw?.[problem.from]
const calculated = this.get(problem.from, problem.where)
this.set(problem.to, raw || calculated, problem.where)
this.delete(problem.from, problem.where)
}
}
Expand Down
12 changes: 12 additions & 0 deletions workspaces/config/tap-snapshots/test/index.js.test.cjs
Expand Up @@ -25,6 +25,18 @@ exports[`test/index.js TAP credentials management def_auth > other registry 1`]
Object {}
`

exports[`test/index.js TAP credentials management def_authEnv > default registry 1`] = `
Object {
"auth": "\${PATH}",
"password": "",
"username": "<\\u0004�",
}
`

exports[`test/index.js TAP credentials management def_authEnv > other registry 1`] = `
Object {}
`

exports[`test/index.js TAP credentials management def_passNoUser > default registry 1`] = `
Object {
"email": "i@izs.me",
Expand Down
3 changes: 3 additions & 0 deletions workspaces/config/test/index.js
Expand Up @@ -701,6 +701,9 @@ email = i@izs.me
'.npmrc': `_auth = ${Buffer.from('hello:world').toString('base64')}
always-auth = true`,
},
def_authEnv: {
'.npmrc': '_auth = ${PATH}',
},
none_authToken: { '.npmrc': '_authToken = 0bad1de4' },
none_lcAuthToken: { '.npmrc': '_authtoken = 0bad1de4' },
none_emptyConfig: { '.npmrc': '' },
Expand Down