mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-27 10:30:58 -04:00
6
.changeset/fast-chefs-sip.md
Normal file
6
.changeset/fast-chefs-sip.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-config": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`pnpm config set key=value` should work the same as `pnpm config set key value` [#5889](https://github.com/pnpm/pnpm/issues/5889).
|
||||
@@ -77,7 +77,13 @@ export async function handler (opts: ConfigCommandOptions, params: string[]) {
|
||||
}
|
||||
switch (params[0]) {
|
||||
case 'set': {
|
||||
return configSet(opts, params[1], params[2] ?? '')
|
||||
let [key, value] = params.slice(1)
|
||||
if (value == null) {
|
||||
const parts = key.split('=')
|
||||
key = parts.shift()!
|
||||
value = parts.join('=')
|
||||
}
|
||||
return configSet(opts, key, value ?? '')
|
||||
}
|
||||
case 'get': {
|
||||
return configGet(opts, params[1])
|
||||
|
||||
@@ -78,3 +78,41 @@ test('config set in project .npmrc file', async () => {
|
||||
'fetch-retries': '1',
|
||||
})
|
||||
})
|
||||
|
||||
test('config set key=value', async () => {
|
||||
const tmp = tempDir()
|
||||
const configDir = path.join(tmp, 'global-config')
|
||||
fs.mkdirSync(configDir, { recursive: true })
|
||||
fs.writeFileSync(path.join(tmp, '.npmrc'), 'store-dir=~/store')
|
||||
|
||||
await config.handler({
|
||||
dir: process.cwd(),
|
||||
configDir,
|
||||
location: 'project',
|
||||
rawConfig: {},
|
||||
}, ['set', 'fetch-retries=1'])
|
||||
|
||||
expect(readIniFileSync(path.join(tmp, '.npmrc'))).toEqual({
|
||||
'store-dir': '~/store',
|
||||
'fetch-retries': '1',
|
||||
})
|
||||
})
|
||||
|
||||
test('config set key=value, when value contains a "="', async () => {
|
||||
const tmp = tempDir()
|
||||
const configDir = path.join(tmp, 'global-config')
|
||||
fs.mkdirSync(configDir, { recursive: true })
|
||||
fs.writeFileSync(path.join(tmp, '.npmrc'), 'store-dir=~/store')
|
||||
|
||||
await config.handler({
|
||||
dir: process.cwd(),
|
||||
configDir,
|
||||
location: 'project',
|
||||
rawConfig: {},
|
||||
}, ['set', 'foo=bar=qar'])
|
||||
|
||||
expect(readIniFileSync(path.join(tmp, '.npmrc'))).toEqual({
|
||||
'store-dir': '~/store',
|
||||
foo: 'bar=qar',
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user