Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "1.0.5",
"version": "1.0.6",
"type": "module",
"bin": {
"spawn": "cli.js"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/__tests__/update-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ describe("update-check", () => {
expect(execFileSyncCalls[0].file).toBe("curl");
expect(execFileSyncCalls[0].args).toContain("-fsSL");
expect(execFileSyncCalls[0].args.some((a: string) => a.includes("install.sh"))).toBe(true);
// 2. bash to execute fetched script
// 2. bash to execute fetched script via temp file (not -c)
expect(execFileSyncCalls[1].file).toBe("bash");
expect(execFileSyncCalls[1].args[0]).toBe("-c");
expect(execFileSyncCalls[1].args[0]).toMatch(/spawn-install-.*\.sh$/);
// 3. which spawn for binary lookup
expect(execFileSyncCalls[2].file).toBe("which");
expect(execFileSyncCalls[2].args).toEqual([
Expand Down
31 changes: 21 additions & 10 deletions packages/cli/src/update-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,28 @@ function performAutoUpdate(latestVersion: string, jsonOutput = false): void {
throw psResult.error;
}
} else {
// macOS/Linux: execute via bash -c
executor.execFileSync(
"bash",
[
"-c",
scriptContent,
],
{
stdio: installStdio,
},
// macOS/Linux: write to temp file and execute via bash to avoid
// command injection and ARG_MAX limits (consistent with Windows path)
const tmpFile = path.join(tmpdir(), `spawn-install-${Date.now()}.sh`);
Comment thread
louisgv marked this conversation as resolved.
fs.writeFileSync(tmpFile, scriptContent, {
mode: 0o700,
});
const bashResult = tryCatch(() =>
executor.execFileSync(
"bash",
[
tmpFile,
],
{
stdio: installStdio,
},
),
);
// Best-effort cleanup of temp file
tryCatchIf(isFileError, () => fs.unlinkSync(tmpFile));
Comment thread
louisgv marked this conversation as resolved.
if (!bashResult.ok) {
throw bashResult.error;
}
}
});

Expand Down
Loading