Add Windows portability guards for workspace flows (#1311)

* Add Windows portability guards for workspace flows

* Increase snapshot workflow timeout

* Trigger CI after timeout update

* Fix windows portability PR after main merge

---------

Co-authored-by: neubig <398875+neubig@users.noreply.github.com>
This commit is contained in:
Graham Neubig
2026-06-12 19:14:03 -04:00
committed by GitHub
co-authored by neubig
parent 197588cc8e
commit df93ca36a7
8 changed files with 275 additions and 40 deletions
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { existsSync } from "node:fs";
import { dirname, join } from "node:path";
function getNpmInvocation() {
if (process.platform !== "win32") {
return { command: "npm", args: ["run", "typecheck:staged"] };
}
const npmCliPath =
process.env.npm_execpath ??
join(dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
if (existsSync(npmCliPath)) {
return {
command: process.execPath,
args: [npmCliPath, "run", "typecheck:staged"],
};
}
return {
command: process.env.ComSpec ?? "cmd.exe",
args: ["/d", "/s", "/c", "npm run typecheck:staged"],
};
}
const { command, args } = getNpmInvocation();
const result = spawnSync(command, args, {
stdio: "inherit",
windowsHide: true,
});
if (result.error) {
throw result.error;
}
if (result.signal) {
console.error(`typecheck:staged terminated by signal ${result.signal}`);
process.exit(1);
}
process.exit(result.status ?? 1);