Skip to content

Commit 328c3d8

Browse files
nlffritzy
authored andcommitted
fix: repair config items using raw values when possible
closes #6085
1 parent e5ecc7f commit 328c3d8

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

workspaces/config/lib/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,9 @@ class Config {
482482
if (problem.action === 'delete') {
483483
this.delete(problem.key, problem.where)
484484
} else if (problem.action === 'rename') {
485-
const old = this.get(problem.from, problem.where)
486-
this.set(problem.to, old, problem.where)
485+
const raw = this.data.get(problem.where).raw?.[problem.from]
486+
const calculated = this.get(problem.from, problem.where)
487+
this.set(problem.to, raw || calculated, problem.where)
487488
this.delete(problem.from, problem.where)
488489
}
489490
}

workspaces/config/tap-snapshots/test/index.js.test.cjs

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ exports[`test/index.js TAP credentials management def_auth > other registry 1`]
2525
Object {}
2626
`
2727

28+
exports[`test/index.js TAP credentials management def_authEnv > default registry 1`] = `
29+
Object {
30+
"auth": "\${PATH}",
31+
"password": "",
32+
"username": "<\\u0004�",
33+
}
34+
`
35+
36+
exports[`test/index.js TAP credentials management def_authEnv > other registry 1`] = `
37+
Object {}
38+
`
39+
2840
exports[`test/index.js TAP credentials management def_passNoUser > default registry 1`] = `
2941
Object {
3042
"email": "[email protected]",

workspaces/config/test/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,9 @@ email = [email protected]
701701
'.npmrc': `_auth = ${Buffer.from('hello:world').toString('base64')}
702702
always-auth = true`,
703703
},
704+
def_authEnv: {
705+
'.npmrc': '_auth = ${PATH}',
706+
},
704707
none_authToken: { '.npmrc': '_authToken = 0bad1de4' },
705708
none_lcAuthToken: { '.npmrc': '_authtoken = 0bad1de4' },
706709
none_emptyConfig: { '.npmrc': '' },

0 commit comments

Comments
 (0)