From 31ad77ff809429d8d9f2c672c82bf29d6675fab6 Mon Sep 17 00:00:00 2001 From: nlf Date: Thu, 26 Jan 2023 11:08:54 -0800 Subject: [PATCH] fix: repair config items using raw values when possible closes #6085 --- workspaces/config/lib/index.js | 5 +++-- .../config/tap-snapshots/test/index.js.test.cjs | 12 ++++++++++++ workspaces/config/test/index.js | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/workspaces/config/lib/index.js b/workspaces/config/lib/index.js index 1ddf267839195..6520e5616ff41 100644 --- a/workspaces/config/lib/index.js +++ b/workspaces/config/lib/index.js @@ -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) } } diff --git a/workspaces/config/tap-snapshots/test/index.js.test.cjs b/workspaces/config/tap-snapshots/test/index.js.test.cjs index 6680fd2377960..eccdbee3abced 100644 --- a/workspaces/config/tap-snapshots/test/index.js.test.cjs +++ b/workspaces/config/tap-snapshots/test/index.js.test.cjs @@ -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", diff --git a/workspaces/config/test/index.js b/workspaces/config/test/index.js index d7d55c2366237..99c1c3647ef77 100644 --- a/workspaces/config/test/index.js +++ b/workspaces/config/test/index.js @@ -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': '' },