Files
AgendaPro/scripts/run-tsx.mjs
T

35 lines
945 B
JavaScript

import os from "node:os";
// tsx creates a temporary directory using os.userInfo(). On some Windows
// runners that syscall fails even though the rest of Node is healthy.
// Keep the normal implementation when it works and provide a safe fallback.
const nativeUserInfo = os.userInfo.bind(os);
const safeUserInfo = (...args) => {
try {
return nativeUserInfo(...args);
} catch {
const username = (process.env.USERNAME || process.env.USER || "agendapro").replace(/[<>:"/\\|?*]/g, "-");
return {
uid: -1,
gid: -1,
username,
homedir: os.homedir(),
shell: null,
};
}
};
try {
os.userInfo = safeUserInfo;
} catch {
Object.defineProperty(os, "userInfo", { configurable: true, writable: true, value: safeUserInfo });
}
try {
await import("tsx/cli");
} catch (error) {
console.error("No se pudo iniciar tsx. Ejecuta primero npm run setup.");
console.error(error);
process.exitCode = 1;
}