19 lines
642 B
TypeScript
19 lines
642 B
TypeScript
import { existsSync } from "node:fs";
|
|
import { execSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname } from "node:path";
|
|
|
|
const dir = dirname(fileURLToPath(import.meta.url));
|
|
|
|
if (!existsSync(`${dir}/node_modules`)) {
|
|
console.log("node_modules not found, installing dependencies...");
|
|
try {
|
|
execSync("bun install --frozen-lockfile", { stdio: "inherit", cwd: dir, timeout: 120_000 });
|
|
} catch {
|
|
console.log("bun unavailable, falling back to npm...");
|
|
execSync("npm install --no-fund --no-audit", { stdio: "inherit", cwd: dir, timeout: 120_000 });
|
|
}
|
|
}
|
|
|
|
await import("./entry.ts");
|