Skip to content

Commit

Permalink
Update _main.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Nov 7, 2023
1 parent 2c6ff16 commit 6e0d0d5
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions _main.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import { spawn } from "node:child_process";
import { dirname, join } from "node:path";
import { once } from "node:events";
import { join, dirname } from "node:path";
import { existsSync } from "node:fs";
const file = join(dirname(process.argv[1]), "main.ts"); // 👈 CHANGE ME!
const subprocess = spawn(`exec "$__FILE"`, {
shell: "bash",
stdio: "inherit",
env: { ...process.env, __FILE: file },
});
await once(subprocess, "spawn");
subprocess.on("exit", (x) => process.exit(x));
const response = await fetch("https://deno.com/versions.json");
const json = await response.json();
const tag = json.cli.find((x) => x.startsWith("v1."));
const version = tag.slice(1);
const DENO_INSTALL = join(
process.env.RUNNER_TOOL_CACHE,
"deno",
version,
process.arch,
);
if (!existsSync(DENO_INSTALL)) {
const subprocess1 = spawn(
`curl -fsSL https://deno.land/x/install/install.sh | sh -s "$tag"`,
{ shell: "bash", env: { ...process.env, DENO_INSTALL, tag } },
);
await once(subprocess1, "exit");
}
const subprocess2 = spawn(
join(DENO_INSTALL, "bin", "deno"),
["run", "-Aq", file],
{ stdio: "inherit" },
);
await once(subprocess2, "spawn");
subprocess2.on("exit", (x) => process.exit(x));

0 comments on commit 6e0d0d5

Please sign in to comment.