Skip to content

Commit f18d8b8

Browse files
committed
Cannot directly run the sudo_install due to perms
We don’t want to allow-read all if possible, we only have to with the sudo variant because Deno sucks. Possible solution would be to output a shell script to do all the hard links and run that `sudo`
1 parent b5046b6 commit f18d8b8

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

pkgm.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function install(args: string[]) {
8282
})
8383
.spawn();
8484

85-
const status = await proc.status;
85+
let status = await proc.status;
8686

8787
if (!status.success) {
8888
Deno.exit(status.code);
@@ -109,26 +109,22 @@ async function install(args: string[]) {
109109
const pkgx_dir = Deno.env.get("PKGX_DIR") || `${Deno.env.get("HOME")}/.pkgx`;
110110
const needs_sudo = Deno.uid() != 0;
111111

112-
if (needs_sudo) {
113-
args = [
114-
"pkgx",
115-
"deno^2.1",
116-
"run",
117-
"--ext=ts",
118-
"--allow-write", // cannot be qualified ∵ `Deno.link()` requires full access for some reason
119-
`--allow-read`, // same ^^ 😕
120-
self,
121-
"sudo-install",
122-
pkgx_dir,
123-
...to_install,
124-
];
125-
const cmd = "/usr/bin/sudo";
126-
const status = await new Deno.Command(cmd, { args, env, clearEnv: true })
127-
.spawn().status;
128-
Deno.exit(status.code);
129-
} else {
130-
await sudo_install(pkgx_dir, to_install);
131-
}
112+
args = [
113+
"pkgx",
114+
"deno^2.1",
115+
"run",
116+
"--ext=ts",
117+
"--allow-write", // cannot be qualified ∵ `Deno.link()` requires full access for some reason
118+
`--allow-read`, // same ^^ 😕
119+
self,
120+
"sudo-install",
121+
pkgx_dir,
122+
...to_install,
123+
];
124+
const cmd = needs_sudo ? "/usr/bin/sudo" : args.shift()!;
125+
status = await new Deno.Command(cmd, { args, env, clearEnv: true })
126+
.spawn().status;
127+
Deno.exit(status.code);
132128
}
133129

134130
async function sudo_install(pkgx_dir: string, pkg_prefixes: string[]) {

0 commit comments

Comments
 (0)