Skip to content
Merged
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
22 changes: 12 additions & 10 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function install(args: string[]) {
})
.spawn();

let status = await proc.status;
const status = await proc.status;

if (!status.success) {
Deno.exit(status.code);
Expand All @@ -107,9 +107,10 @@ async function install(args: string[]) {

const self = fromFileUrl(import.meta.url);
const pkgx_dir = Deno.env.get("PKGX_DIR") || `${Deno.env.get("HOME")}/.pkgx`;
const needs_sudo = Deno.uid() != 0;

status = await new Deno.Command("/usr/bin/sudo", {
args: [
if (needs_sudo) {
args = [
"pkgx",
"deno^2.1",
"run",
Expand All @@ -120,13 +121,14 @@ async function install(args: string[]) {
"sudo-install",
pkgx_dir,
...to_install,
],
env,
clearEnv: true,
})
.spawn().status;

Deno.exit(status.code);
];
const cmd = "/usr/bin/sudo";
const status = await new Deno.Command(cmd, { args, env, clearEnv: true })
.spawn().status;
Deno.exit(status.code);
} else {
await sudo_install(pkgx_dir, to_install);
}
}

async function sudo_install(pkgx_dir: string, pkg_prefixes: string[]) {
Expand Down
Loading