Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for production install #251

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/yarn@berry.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', 'npm i -g eslint ni'))

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

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