zidane-gui 7.1.9 → 7.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ import { execFile } from "node:child_process";
2
+ import { access } from "node:fs/promises";
3
+ import { join, delimiter } from "node:path";
4
+ const MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
5
+ async function exists(p) {
6
+ return access(p).then(
7
+ () => true,
8
+ () => false
9
+ );
10
+ }
11
+ async function resolveOnPath(name) {
12
+ const exts = process.platform === "win32" ? [".cmd", ".exe", ""] : [""];
13
+ for (const dir of (process.env.PATH ?? "").split(delimiter)) {
14
+ if (!dir) continue;
15
+ for (const ext of exts) {
16
+ const candidate = join(dir, name + ext);
17
+ if (await exists(candidate)) return candidate;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ function makeToolContext(cwd, timeoutMs) {
23
+ return {
24
+ cwd,
25
+ async resolveBin(name) {
26
+ const local = join(cwd, "node_modules", ".bin", name);
27
+ if (await exists(local)) return local;
28
+ return resolveOnPath(name);
29
+ },
30
+ async hasFile(...names) {
31
+ for (const n of names) if (await exists(join(cwd, n))) return true;
32
+ return false;
33
+ },
34
+ exec(bin, args, opts) {
35
+ return new Promise((done) => {
36
+ const child = execFile(
37
+ bin,
38
+ [...args],
39
+ {
40
+ cwd,
41
+ timeout: opts?.timeoutMs ?? timeoutMs,
42
+ maxBuffer: MAX_OUTPUT_BYTES,
43
+ env: { ...process.env, FORCE_COLOR: "0", NO_COLOR: "1" }
44
+ },
45
+ (err, stdout, stderr) => {
46
+ const killed = err?.killed === true;
47
+ done({
48
+ stdout: String(stdout ?? ""),
49
+ stderr: String(stderr ?? ""),
50
+ code: child.exitCode,
51
+ timedOut: killed
52
+ });
53
+ }
54
+ );
55
+ });
56
+ }
57
+ };
58
+ }
59
+ export {
60
+ makeToolContext as m
61
+ };