Skip to content

Commit

Permalink
fix: pnpm config get <key> -g returns empty when the value is a boo…
Browse files Browse the repository at this point in the history
…lean
  • Loading branch information
lvqq committed Apr 5, 2023
1 parent e440d78 commit 1a51cd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/little-badgers-sort.md
@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-config": patch
---

`pnpm config get <key>` returns empty when the value is a boolean
3 changes: 2 additions & 1 deletion config/plugin-commands-config/src/configGet.ts
@@ -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
}
14 changes: 14 additions & 0 deletions config/plugin-commands-config/test/configGet.test.ts
Expand Up @@ -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')
})

0 comments on commit 1a51cd6

Please sign in to comment.