mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-15 20:16:07 -04:00
* refactor(config): return type annotations * refactor: simplify configGet * test: fix typescript errors * feat(config): get on array * feat(config): use comma instead * lint: fix
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
import { config } from '@pnpm/plugin-commands-config'
|
|
|
|
test('config get', async () => {
|
|
const configKey = await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir: process.cwd(),
|
|
global: true,
|
|
rawConfig: {
|
|
'store-dir': '~/store',
|
|
},
|
|
}, ['get', 'store-dir'])
|
|
|
|
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')
|
|
})
|
|
|
|
test('config get on array should return a comma-separated list', async () => {
|
|
const configKey = await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir: process.cwd(),
|
|
global: true,
|
|
rawConfig: {
|
|
'public-hoist-pattern': [
|
|
'*eslint*',
|
|
'*prettier*',
|
|
],
|
|
},
|
|
}, ['get', 'public-hoist-pattern'])
|
|
|
|
expect(configKey).toBe('*eslint*,*prettier*')
|
|
})
|
|
|
|
test('config get without key show list all settings ', async () => {
|
|
const rawConfig = {
|
|
'store-dir': '~/store',
|
|
'fetch-retries': '2',
|
|
}
|
|
const getOutput = await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir: process.cwd(),
|
|
global: true,
|
|
rawConfig,
|
|
}, ['get'])
|
|
|
|
const listOutput = await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir: process.cwd(),
|
|
rawConfig,
|
|
}, ['list'])
|
|
|
|
expect(getOutput).toEqual(listOutput)
|
|
})
|