Skip to content

Commit

Permalink
fix: repair config items using raw values when possible
Browse files Browse the repository at this point in the history
closes #6085
  • Loading branch information
nlf authored and fritzy committed Feb 1, 2023
1 parent e5ecc7f commit 328c3d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions workspaces/config/lib/index.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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": "[email protected]",
Expand Down
3 changes: 3 additions & 0 deletions workspaces/config/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,9 @@ email = [email protected]
'.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

0 comments on commit 328c3d8

Please sign in to comment.