fix: pnpm config get <key> -g returns empty when the value is a boolean (#6360)

This commit is contained in:
chlorine
2023-04-06 08:39:24 +08:00
committed by GitHub
parent 41562584ab
commit bb287272a0
3 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-config": patch
---
`pnpm config get <key>` returns empty when the value is a boolean

View File

@@ -1,5 +1,6 @@
import { type ConfigCommandOptions } from './ConfigCommandOptions'
export function configGet (opts: ConfigCommandOptions, key: string) {
return opts.rawConfig[key]
const config = opts.rawConfig[key]
return typeof config === 'boolean' ? config.toString() : config
}

View File

@@ -13,3 +13,17 @@ test('config get', async () => {
expect(configKey).toEqual('~/store')
})
test('config get a boolean should return string format', async () => {
const configKey = await config.handler({
dir: process.cwd(),
cliOptions: {},
configDir: process.cwd(),
global: true,
rawConfig: {
'update-notifier': true,
},
}, ['get', 'update-notifier'])
expect(configKey).toEqual('true')
})