8000 fix: forward args for `ni`, close #73 · antfu-collective/ni@3a63f07 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 3a63f07

Browse files
committed
fix: forward args for ni, close #73
1 parent a150c9a commit 3a63f07

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/agents.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const npmRun = (agent: string) => (args: string[]) => {
77
export const AGENTS = {
88
'npm': {
99
'run': npmRun('npm'),
10-
'install': 'npm i',
10+
'install': 'npm i {0}',
1111
'frozen': 'npm ci',
1212
'global': 'npm i -g {0}',
1313
'add': 'npm i {0}',
@@ -19,7 +19,7 @@ export const AGENTS = {
1919
},
2020
'yarn': {
2121
'run': 'yarn run {0}',
22-
'install': 'yarn install',
22+
'install': 'yarn install {0}',
2323
'frozen': 'yarn install --frozen-lockfile',
2424
'global': 'yarn global add {0}',
2525
'add': 'yarn add {0}',
@@ -31,7 +31,7 @@ export const AGENTS = {
3131
},
3232
'yarn@berry': {
3333
'run': 'yarn run {0}',
34-
'install': 'yarn install',
34+
'install': 'yarn install {0}',
3535
'frozen': 'yarn install --immutable',
3636
// yarn3 removed 'global', see https://github.com/yarnpkg/berry/issues/821
3737
'global': 'npm i -g {0}',
@@ -44,7 +44,7 @@ export const AGENTS = {
4444
},
4545
'pnpm': {
4646
'run': npmRun('pnpm'),
47-
'install': 'pnpm i',
47+
'install': 'pnpm i {0}',
4848
'frozen': 'pnpm i --frozen-lockfile',
4949
'global': 'pnpm add -g {0}',
5050
'add': 'pnpm add {0}',

src/commands.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@ export const parseNi = <Runner>((agent, args, ctx) => {
2929
process.exit(0)
3030
}
3131

32-
if (args.length === 0)
33-
return getCommand(agent, 'install')
34-
3532
if (args.includes('-g'))
3633
return getCommand(agent, 'global', exclude(args, '-g'))
3734

38-
if (args.length === 1 && args[0] === '-f')
39-
return getCommand(agent, 'install', args)
40-
4135
if (args.includes('--frozen-if-present')) {
4236
args = exclude(args, '--frozen-if-present')
4337
return getCommand(agent, ctx?.hasLock ? 'frozen' : 'install', args)
@@ -46,6 +40,9 @@ export const parseNi = <Runner>((agent, args, ctx) => {
4640
if (args.includes('--frozen'))
4741
return getCommand(agent, 'frozen', exclude(args, '--frozen'))
4842

43+
if (args.length === 0 || args.every(i => i.startsWith('-')))
44+
return getCommand(agent, 'install', args)
45+
4946
return getCommand(agent, 'add', args)
5047
})
5148

test/ni/pnpm.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ test('-D', _('-D eslint @types/node', 'pnpm add -D eslint @types/node'))
2121
test('global', _('eslint -g', 'pnpm add -g eslint'))
2222

2323
test('frozen', _('--frozen', 'pnpm i --frozen-lockfile'))
24+
25+
test('forward1', _('--anything', 'pnpm i --anything'))
26+
test('forward2', _('-a', 'pnpm i -a'))

0 commit comments

Comments
 (0)
0