8000 feat: new `nun` command for uninstall (#69) · antfu-collective/ni@3c0d769 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 3c0d769

Browse files
authored
feat: new nun command for uninstall (#69)
1 parent 612d02a commit 3c0d769

File tree

9 files changed

+116
-3
lines changed

9 files changed

+116
-3
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,34 @@ nu -i
121121

122122
<br>
123123

124+
### `nun` - uninstall
125+
126+
```bash
127+
nun axios
128+
129+
# npm uninstall axios
130+
# yarn remove axios
131+
# pnpm remove axios
132+
```
133+
134+
```bash
135+
nun @types/node -D
136+
137+
# npm uninstall @types/node -D
138+
# yarn remove @types/node -D
139+
# pnpm remove -D @types/node
140+
```
141+
142+
```bash
143+
nun -g eslint
144+
145+
# npm uninstall -g eslint
146+
# yarn global remove eslint
147+
# pnpm remove -g eslint
148+
```
149+
150+
<br>
151+
124152
### `nci` - clean install
125153

126154
```bash

bin/nun.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
'use strict'
3+
require('../dist/nun')

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"nci": "bin/nci.js",
2121
"nr": "bin/nr.js",
2222
"nu": "bin/nu.js",
23-
"nx": "bin/nx.js"
23+
"nx": "bin/nx.js",
24+
"nun": "bin/nun.js"
2425
},
2526
"bugs": {
2627
"url": "https://github.com/antfu/ni/issues"
@@ -35,8 +36,9 @@
3536
"nr": "esno src/nr.ts",
3637
"nu": "esno src/nu.ts",
3738
"nx": "esno src/nx.ts",
39+
"nun": "esno src/nun.ts",
3840 "dev": "esno src/ni.ts",
39-
"build": "rimraf dist && tsup src/ni.ts src/nci.ts src/nr.ts src/nu.ts src/nx.ts src/index.ts --format cjs,esm --dts",
41+
"build": "rimraf dist && tsup src/ni.ts src/nci.ts src/nr.ts src/nu.ts src/nx.ts src/nun.ts src/index.ts --format cjs,esm --dts",
4042
"release": "npx bumpp --commit --push --tag",
4143
"lint": "eslint \"**/*.ts\"",
4244
"lint:fix": "npm run lint -- --fix",

src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const parseNu = <Runner>((agent, args) => {
6767
return getCommand(agent, 'upgrade', args)
6868
})
6969

70-
export const parseNrm = <Runner>((agent, args) => {
70+
export const parseNun = <Runner>((agent, args) => {
7171
if (args.includes('-g'))
7272
return getCommand(agent, 'global_uninstall', exclude(args, '-g'))
7373
return getCommand(agent, 'uninstall', args)

src/nun.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { parseNun } from './commands'
2+
import { runCli } from './runner'
3+
4+
runCli(parseNun)

test/nun/npm.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test, expect } from 'vitest'
2+
import { parseNun } from '../../src/commands'
3+
4+
const agent = 'npm'
5+
const _ = (arg: string, expected: string) => () => {
6+
expect(
7+
parseNun(agent, arg.split(' ').filter(Boolean)),
8+
).toBe(
9+
expected,
10+
)
11+
}
12+
13+
test('single uninstall', _('axios', 'npm uninstall axios'))
14+
15+
test('multiple', _('eslint @types/node', 'npm uninstall eslint @types/node'))
16+
17+
test('-D', _('eslint @types/node -D', 'npm uninstall eslint @types/node -D'))
18+
19+
test('global', _('eslint -g', 'npm uninstall -g eslint'))

test/nun/pnpm.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test, expect } from 'vitest'
2+
import { parseNun } from '../../src/commands'
3+
4+
const agent = 'pnpm'
5+
const _ = (arg: string, expected: string) => () => {
6+
expect(
7+
parseNun(agent, arg.split(' ').filter(Boolean)),
8+
).toBe(
9+
expected,
10+
)
11+
}
12+
13+
test('single add', _('axios', 'pnpm remove axios'))
14+
15+
test('multiple', _('eslint @types/node', 'pnpm remove eslint @types/node'))
16+
17+
test('-D', _('-D eslint @types/node', 'pnpm remove -D eslint @types/node'))
18+
19+
test('global', _('eslint -g', 'pnpm remove --global eslint'))

test/nun/yarn.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test, expect } from 'vitest'
2+
import { parseNun } from '../../src/commands'
3+
4+
const agent = 'yarn'
5+
const _ = (arg: string, expected: string) => () => {
6+
expect(
7+
parseNun(agent, arg.split(' ').filter(Boolean)),
8+
).toBe(
9+
expected,
10+
)
11+
}
12+
13+
test('single uninstall', _('axios', 'yarn remove axios'))
14+
15+
test('multiple', _('eslint @types/node', 'yarn remove eslint @types/node'))
16+
17+
test('-D', _('eslint @types/node -D', 'yarn remove eslint @types/node -D'))
18+
19+
test('global', _('eslint ni -g', 'yarn global remove eslint ni'))

test/nun/yarn@berry.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test, expect } from 'vitest'
2+
import { parseNun } from '../../src/commands'
3+
4+
const agent = 'yarn@berry'
5+
const _ = (arg: string, expected: string) => () => {
6+
expect(
7+
parseNun(agent, arg.split(' ').filter(Boolean)),
8+
).toBe(
9+
expected,
10+
)
11+
}
12+
13+
test('single add', _('axios', 'yarn remove axios'))
14+
15+
test('multiple', _('eslint @types/node', 'yarn remove eslint @types/node'))
16+
17+
test('-D', _('eslint @types/node -D', 'yarn remove eslint @types/node -D'))
18+
19+
test('global', _('eslint ni -g', 'npm uninstall -g eslint ni'))

0 commit comments

Comments
 (0)
0