generated from garronej/ts-ci
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.ts
92 lines (69 loc) 路 2.7 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const __dirname = (() => {
const { url: urlStr } = import.meta;
const url = new URL(urlStr);
const __filename = (url.protocol === "file:" ? url.pathname : urlStr)
.replace(/[/][^/]*$/, '');
const isWindows = (() => {
let NATIVE_OS: typeof Deno.build.os = "linux";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const navigator = (globalThis as any).navigator;
if (globalThis.Deno != null) {
NATIVE_OS = Deno.build.os;
} else if (navigator?.appVersion?.includes?.("Win") ?? false) {
NATIVE_OS = "windows";
}
return NATIVE_OS == "windows";
})();
return isWindows ?
__filename.split("/").join("\\").substring(1) :
__filename;
})();
const __filename = (() => {
const { url: urlStr } = import.meta;
const url = new URL(urlStr);
const __filename = (url.protocol === "file:" ? url.pathname : urlStr);
const isWindows = (() => {
let NATIVE_OS: typeof Deno.build.os = "linux";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const navigator = (globalThis as any).navigator;
if (globalThis.Deno != null) {
NATIVE_OS = Deno.build.os;
} else if (navigator?.appVersion?.includes?.("Win") ?? false) {
NATIVE_OS = "windows";
}
return NATIVE_OS == "windows";
})();
return isWindows ?
__filename.split("/").join("\\").substring(1) :
__filename;
})();
//This will not run on deno, we need a separate test runner for Deno (./mod.ts).
import * as child_process from "child_process DENOIFY: DEPENDENCY UNMET (BUILTIN)";
import * as path from "https://deno.land/std@0.85.0/node/path.ts";
import { Deferred } from "https://raw.githubusercontent.com/garronej/evt/v1.9.14/deno_dist/tools/Deferred.ts";
const names = ["withDefault", "flip", "objectKeys", "isPromiseLike", "assertIs", "exclude"];
(async () => {
if (!!process.env.FORK) {
process.once("unhandledRejection", error => {
throw error;
});
require(process.env.FORK);
return;
}
for (const name of names) {
console.log(`Running: ${name}`);
const dExitCode = new Deferred<number>();
child_process
.fork(__filename, undefined, {
"env": { "FORK": path.join(__dirname, name) },
})
.on("message", console.log)
.once("exit", code => dExitCode.resolve(code ?? 1));
const exitCode = await dExitCode.pr;
if (exitCode !== 0) {
console.log(`${name} exited with error code: ${exitCode}`);
process.exit(exitCode);
}
console.log("\n");
}
})();