-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import parse_pkg_str from "../prefab/parse-pkg-str.ts" | ||
import { hooks, PackageRequirement, Path, PkgxError } from "pkgx" | ||
|
||
export default async function(pkgspecs: string[]) { | ||
const pkgs = await Promise.all(pkgspecs.map(x => parse_pkg_str(x, {latest: 'ok'}))) | ||
|
||
await uninstall(new Path("/usr/local/bin"), pkgs) | ||
await uninstall(Path.home().join(".local/bin"), pkgs) | ||
} | ||
|
||
async function uninstall(prefix: Path, pkgs: PackageRequirement[]) { | ||
for (const pkg of pkgs) { | ||
const programs = await hooks.usePantry().project(pkg).provides() | ||
for (const program of programs) { | ||
const f = prefix.join(program) | ||
if (f.isFile()) { | ||
const cmd = new Deno.Command(f.string, {env: {PKGX_UNINSTALL: '1'}}) | ||
const proc = await cmd.spawn().status | ||
if (!proc.success) { | ||
throw new PkgxError(`Couldn’t uninstall: ${f}`) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters