Skip to content

Commit

Permalink
feat: add uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Jun 10, 2023
1 parent ac9480f commit a476e31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
getPackageCommands,
PM_LOCKS,
} from "./src/pm.ts"
import { execa, execaInstall } from "./src/process.ts"
import { execa, execaInstall, execaUnInstall } from "./src/process.ts"
import { version } from "./src/version.ts"

import type { Options, PM } from "./src/type.ts"
Expand Down Expand Up @@ -163,10 +163,17 @@ if (import.meta.main) {
])
})

const uninstall = new Command().alias("uninstall").alias("rm").description(
`${brightGreen(pm)} uninstall deps`,
).arguments("<...deps:string>").action(async (_, ...deps) => {
await execaUnInstall(pm, deps)
})

await commander
.command("in", init)
.command("i", install)
.command("ri", reinstall)
.command("un", uninstall)
.command("sw", _switch)
.parse(Deno.args)
}
5 changes: 5 additions & 0 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export function execaInstall(
)
}

export function execaUnInstall(pm: PM, deps: string[]) {
const isNpm = pm === "npm"
return execa([pm, isNpm ? "uninstall" : "remove", ...deps])
}

export function gracefulShutdown(shutdown: AnyFunction) {
async function exitWithShoutdown() {
await shutdown()
Expand Down

0 comments on commit a476e31

Please sign in to comment.