Skip to content

Commit

Permalink
feat: add support for production install (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorePlusPlus authored Jan 25, 2025
1 parent 59f70ff commit 76d3540
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ ni @types/node -D
# bun add -d @types/node
```

```bash
ni -P

# npm i --omit=dev
# yarn install --production
# pnpm i --production
# bun install --production
```

```bash
ni --frozen

Expand Down
7 changes: 7 additions & 0 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export const parseNi = <Runner>((agent, args, ctx) => {
if (agent === 'bun')
args = args.map(i => i === '-D' ? '-d' : i)

// npm use `--omit=dev` instead of `--production`
if (agent === 'npm')
args = args.map(i => i === '-P' ? '--omit=dev' : i)

if (args.includes('-P'))
args = args.map(i => i === '-P' ? '--production' : i)

if (args.includes('-g'))
return getCommand(agent, 'global', exclude(args, '-g'))

Expand Down
2 changes: 2 additions & 0 deletions test/ni/bun.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ it('multiple', _('eslint @types/node', 'bun add eslint @types/node'))
it('global', _('eslint -g', 'bun add -g eslint'))

it('frozen', _('--frozen', 'bun install --frozen-lockfile'))

it('production', _('-P', 'bun install --production'))
2 changes: 2 additions & 0 deletions test/ni/npm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ it('-D', _('eslint @types/node -D', 'npm i eslint @types/node -D'))
it('global', _('eslint -g', 'npm i -g eslint'))

it('frozen', _('--frozen', 'npm ci'))

it('production', _('-P', 'npm i --omit=dev'))
2 changes: 2 additions & 0 deletions test/ni/pnpm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ it('frozen', _('--frozen', 'pnpm i --frozen-lockfile'))

it('forward1', _('--anything', 'pnpm i --anything'))
it('forward2', _('-a', 'pnpm i -a'))

it('production', _('-P', 'pnpm i --production'))
2 changes: 2 additions & 0 deletions test/ni/yarn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ it('-D', _('eslint @types/node -D', 'yarn add eslint @types/node -D'))
it('global', _('eslint ni -g', 'yarn global add eslint ni'))

it('frozen', _('--frozen', 'yarn install --frozen-lockfile'))

it('production', _('-P', 'yarn install --production'))
2 changes: 2 additions & 0 deletions test/ni/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ it('-D', _('eslint @types/node -D', 'yarn add eslint @types/node -D'))
it('global', _('eslint ni -g', 'npm i -g eslint ni'))

it('frozen', _('--frozen', 'yarn install --immutable'))

it('production', _('-P', 'yarn install --production'))

0 comments on commit 76d3540

Please sign in to comment.