Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ensure-electron-runtime.test.mjs

29 lines1.2 KB

1import assert from "node:assert/strict";
2import * as NodeFS from "node:fs";
3import * as NodeOS from "node:os";
4import * as NodePath from "node:path";
5import test from "node:test";
6​
7import { createElectronInstallInvocation } from "./ensure-electron-runtime.mjs";
8​
9test("Electron repair reuses Electron's own installer without external curl/python", () => {
10 const root = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "electron repair José "));
11 const installScript = NodePath.join(root, "install.js");
12 NodeFS.writeFileSync(installScript, "// fixture\n");
13​
14 try {
15 const invocation = createElectronInstallInvocation(root, {
16 ELECTRON_SKIP_BINARY_DOWNLOAD: "1",
17 ELECTRON_MIRROR: "https://mirror.example.invalid/",
18 PATH: process.env.PATH,
19 });
20​
21 assert.equal(invocation.command, process.execPath);
22 assert.deepEqual(invocation.args, [installScript]);
23 assert.equal(invocation.cwd, root);
24 assert.equal(invocation.env.ELECTRON_SKIP_BINARY_DOWNLOAD, undefined);
25 assert.equal(invocation.env.ELECTRON_MIRROR, "https://mirror.example.invalid/");
26 } finally {
27 NodeFS.rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
28 }
29});