Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build/globals.js",
"build/deno.js"
],
"limit": "847.80 kB",
"limit": "847.90 kB",
"brotli": false,
"gzip": false
},
Expand Down Expand Up @@ -66,7 +66,7 @@
"README.md",
"LICENSE"
],
"limit": "909.40 kB",
"limit": "909.50 kB",
"brotli": false,
"gzip": false
}
Expand Down
7 changes: 5 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ function linkNodeModules(cwd: string, external: string): string {
function lstat(p: string) {
try {
return fs.lstatSync(p)
} catch {}
} catch {
// File does not exist — return undefined.
}
}

async function readScript() {
Expand Down Expand Up @@ -247,7 +249,8 @@ async function readScriptFromHttp(remote: string): Promise<string> {
const res = await fetch(remote)
if (!res.ok) {
console.error(`Error: Can't get ${remote}`)
process.exit(1)
process.exitCode = 1
throw new Fail(`Failed to fetch remote script: ${remote} (${res.status})`)
}
return res.text()
}
Expand Down
16 changes: 13 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,9 @@ try {
if (isString(shell)) $.shell = shell
if (isString(prefix)) $.prefix = prefix
if (isString(postfix)) $.postfix = postfix
} catch (err) {}
} catch (err) {
// Bash may not be available (e.g. on Windows). Fall back to the default shell.
}

let cwdSyncHook: AsyncHook

Expand Down Expand Up @@ -1056,17 +1058,25 @@ export async function kill(
)
return

// Kill all child processes in the tree. Errors are expected here since
// processes may have already exited by the time we attempt to kill them.
for (const p of await ps.tree({ pid, recursive: true })) {
try {
process.kill(+p.pid, signal)
} catch (e) {}
} catch (e) {
// Process already exited.
}
}
try {
// Try killing the process group first (negative pid).
process.kill(-pid, signal)
} catch (e) {
try {
// If process group kill fails, try killing the process directly.
process.kill(+pid, signal)
} catch (e) {}
} catch (e) {
// Process already exited.
}
}
}

Expand Down