@reventlessdev/reventless-gwt 1.0.0-alpha.74
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.
- package/CHANGELOG.md +698 -0
- package/LICENSE +202 -0
- package/bin/reventless-dev.mjs +21 -0
- package/package.json +54 -0
- package/rescript.json +36 -0
- package/src/.gwtignore +10 -0
- package/src/Automation_GWT.res +207 -0
- package/src/Automation_GWT.res.mjs +160 -0
- package/src/Behavior_GWT.res +603 -0
- package/src/Behavior_GWT.res.mjs +426 -0
- package/src/Bind.res +29 -0
- package/src/Bind.res.mjs +22 -0
- package/src/BuildClassifier.res +137 -0
- package/src/BuildClassifier.res.mjs +136 -0
- package/src/Cancellation.res +31 -0
- package/src/Cancellation.res.mjs +45 -0
- package/src/ChildProcess.res +84 -0
- package/src/ChildProcess.res.mjs +92 -0
- package/src/Cli.res +671 -0
- package/src/Cli.res.mjs +754 -0
- package/src/Collector.res +201 -0
- package/src/Collector.res.mjs +215 -0
- package/src/ComponentMeta.res +104 -0
- package/src/ComponentMeta.res.mjs +120 -0
- package/src/ComponentScan.res +103 -0
- package/src/ComponentScan.res.mjs +105 -0
- package/src/Delegate_GWT.res +303 -0
- package/src/Delegate_GWT.res.mjs +372 -0
- package/src/Diff.res +91 -0
- package/src/Diff.res.mjs +98 -0
- package/src/Discovery.res +105 -0
- package/src/Discovery.res.mjs +103 -0
- package/src/DomainDeadCode.res +93 -0
- package/src/DomainDeadCode.res.mjs +69 -0
- package/src/DomainGraph.res +0 -0
- package/src/DomainGraph.res.mjs +0 -0
- package/src/EventMapping_GWT.res +29 -0
- package/src/EventMapping_GWT.res.mjs +44 -0
- package/src/Filter.res +36 -0
- package/src/Filter.res.mjs +40 -0
- package/src/Flow_GWT.res +664 -0
- package/src/Flow_GWT.res.mjs +604 -0
- package/src/FormatterHuman.res +138 -0
- package/src/FormatterHuman.res.mjs +122 -0
- package/src/FormatterJson.res +257 -0
- package/src/FormatterJson.res.mjs +320 -0
- package/src/FormatterJunit.res +93 -0
- package/src/FormatterJunit.res.mjs +90 -0
- package/src/FormatterTap.res +139 -0
- package/src/FormatterTap.res.mjs +149 -0
- package/src/FormatterVsCode.res +362 -0
- package/src/FormatterVsCode.res.mjs +564 -0
- package/src/Hint.res +119 -0
- package/src/Hint.res.mjs +124 -0
- package/src/InboundTranslation_GWT.res +83 -0
- package/src/InboundTranslation_GWT.res.mjs +94 -0
- package/src/JestBind.res +70 -0
- package/src/JestBind.res.mjs +63 -0
- package/src/Loader.res +24 -0
- package/src/Loader.res.mjs +23 -0
- package/src/LocalHost.res +135 -0
- package/src/LocalHost.res.mjs +127 -0
- package/src/Mapping_GWT.res +474 -0
- package/src/Mapping_GWT.res.mjs +322 -0
- package/src/MultiSourceProjection_GWT.res +316 -0
- package/src/MultiSourceProjection_GWT.res.mjs +354 -0
- package/src/OutboundTranslation_GWT.res +238 -0
- package/src/OutboundTranslation_GWT.res.mjs +186 -0
- package/src/Outcome.res +161 -0
- package/src/Outcome.res.mjs +140 -0
- package/src/PackageScan.res +80 -0
- package/src/PackageScan.res.mjs +81 -0
- package/src/PlatformRunner.res +160 -0
- package/src/PlatformRunner.res.mjs +155 -0
- package/src/PlatformScan.res +138 -0
- package/src/PlatformScan.res.mjs +131 -0
- package/src/ProcessManager.res +91 -0
- package/src/ProcessManager.res.mjs +80 -0
- package/src/Projection_GWT.res +312 -0
- package/src/Projection_GWT.res.mjs +332 -0
- package/src/Query_GWT.res +379 -0
- package/src/Query_GWT.res.mjs +367 -0
- package/src/RenderRescript.res +125 -0
- package/src/RenderRescript.res.mjs +141 -0
- package/src/RunnerTypes.res +68 -0
- package/src/RunnerTypes.res.mjs +60 -0
- package/src/SideEffect_GWT.res +157 -0
- package/src/SideEffect_GWT.res.mjs +113 -0
- package/src/StateChange/ExternalAddCategorySlice.res +25 -0
- package/src/StateChange/ExternalAddCategorySlice.res.mjs +34 -0
- package/src/StateChange/ExternalAddCategorySlice_Behavior.res +19 -0
- package/src/StateChange/ExternalAddCategorySlice_Behavior.res.mjs +46 -0
- package/src/StateChange/WithFixtures.res +22 -0
- package/src/StateChange/WithFixtures.res.mjs +31 -0
- package/src/StateChange/WithFixtures_Behavior.res +17 -0
- package/src/StateChange/WithFixtures_Behavior.res.mjs +37 -0
- package/src/StateChange/WithManualOpen.res +23 -0
- package/src/StateChange/WithManualOpen.res.mjs +31 -0
- package/src/StateChange/WithManualOpen_Behavior.res +17 -0
- package/src/StateChange/WithManualOpen_Behavior.res.mjs +37 -0
- package/src/StubRuntime.res +53 -0
- package/src/StubRuntime.res.mjs +54 -0
- package/src/TestFixtures.res +16 -0
- package/src/TestFixtures.res.mjs +34 -0
- package/src/Watch.res +92 -0
- package/src/Watch.res.mjs +83 -0
- package/src/WatcherProbe.res +48 -0
- package/src/WatcherProbe.res.mjs +46 -0
- package/tests/AutomationGwtTest.res +71 -0
- package/tests/AutomationGwtTest.res.mjs +189 -0
- package/tests/BuildClassifierTest.res +94 -0
- package/tests/BuildClassifierTest.res.mjs +132 -0
- package/tests/ComponentMetaTest.res +52 -0
- package/tests/ComponentMetaTest.res.mjs +57 -0
- package/tests/DelegateGwtTest.res +487 -0
- package/tests/DelegateGwtTest.res.mjs +891 -0
- package/tests/DiscoveryTest.res +42 -0
- package/tests/DiscoveryTest.res.mjs +43 -0
- package/tests/DomainDeadCodeTest.res +116 -0
- package/tests/DomainDeadCodeTest.res.mjs +155 -0
- package/tests/DomainGraphTest.res +365 -0
- package/tests/DomainGraphTest.res.mjs +413 -0
- package/tests/FlowAggregateGwtTest.res +169 -0
- package/tests/FlowAggregateGwtTest.res.mjs +269 -0
- package/tests/FlowCrossPluginGwtTest.res +340 -0
- package/tests/FlowCrossPluginGwtTest.res.mjs +798 -0
- package/tests/FlowGwtTest.res +222 -0
- package/tests/FlowGwtTest.res.mjs +432 -0
- package/tests/FormatterVsCodeMessageTest.res +41 -0
- package/tests/FormatterVsCodeMessageTest.res.mjs +42 -0
- package/tests/InboundTranslationGwtTest.res +34 -0
- package/tests/InboundTranslationGwtTest.res.mjs +98 -0
- package/tests/LocalHostIntegration.res +70 -0
- package/tests/LocalHostIntegration.res.mjs +64 -0
- package/tests/LocalHostTest.res +71 -0
- package/tests/LocalHostTest.res.mjs +63 -0
- package/tests/MappingGwtTest.res +348 -0
- package/tests/MappingGwtTest.res.mjs +592 -0
- package/tests/OutboundTranslationGwtTest.res +59 -0
- package/tests/OutboundTranslationGwtTest.res.mjs +138 -0
- package/tests/PlatformRunnerTest.res +66 -0
- package/tests/PlatformRunnerTest.res.mjs +85 -0
- package/tests/PlatformScanTest.res +61 -0
- package/tests/PlatformScanTest.res.mjs +56 -0
- package/tests/QueryGwtTest.res +161 -0
- package/tests/QueryGwtTest.res.mjs +314 -0
- package/tests/QueryResolverGwtTest.res +71 -0
- package/tests/QueryResolverGwtTest.res.mjs +136 -0
- package/tests/RunnerUnitTest.res +219 -0
- package/tests/RunnerUnitTest.res.mjs +244 -0
- package/tests/SideEffect/FakeOrderNotification.res +23 -0
- package/tests/SideEffect/FakeOrderNotification.res.mjs +36 -0
- package/tests/SideEffect/FakeOrderNotificationGwtTest.res +35 -0
- package/tests/SideEffect/FakeOrderNotificationGwtTest.res.mjs +73 -0
- package/tests/SideEffect/MockEmail.res +18 -0
- package/tests/SideEffect/MockEmail.res.mjs +47 -0
- package/tests/StateChange/ExternalAddCategorySlice_GWT.res +27 -0
- package/tests/StateChange/ExternalAddCategorySlice_GWT.res.mjs +70 -0
- package/tests/StateChange/WithFixtures_Fixtures.res +9 -0
- package/tests/StateChange/WithFixtures_Fixtures.res.mjs +20 -0
- package/tests/StateChange/WithFixtures_GWT.res +23 -0
- package/tests/StateChange/WithFixtures_GWT.res.mjs +56 -0
- package/tests/StateChange/WithManualOpen_Fixtures.res +7 -0
- package/tests/StateChange/WithManualOpen_Fixtures.res.mjs +20 -0
- package/tests/StateChange/WithManualOpen_GWT.res +17 -0
- package/tests/StateChange/WithManualOpen_GWT.res.mjs +56 -0
- package/tests/StateChangeSliceGwtTest.res +160 -0
- package/tests/StateChangeSliceGwtTest.res.mjs +280 -0
- package/tests/StateViewSliceGwtTest.res +64 -0
- package/tests/StateViewSliceGwtTest.res.mjs +161 -0
- package/tests/WatchDebounceTest.res +78 -0
- package/tests/WatchDebounceTest.res.mjs +97 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
let stripAnsi = (s => s.replace(/\x1b\[[0-9;]*m/g, ""));
|
|
5
|
+
|
|
6
|
+
function isStartLine(l) {
|
|
7
|
+
if (l.startsWith("Parsed ")) {
|
|
8
|
+
return l.endsWith("source files");
|
|
9
|
+
} else {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isFinishLine(l) {
|
|
15
|
+
if (l.includes("Finished")) {
|
|
16
|
+
return l.includes("compilation");
|
|
17
|
+
} else {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isErrorMarker(l) {
|
|
23
|
+
if (l.includes("We've found a bug for you!") || l.includes("Syntax error")) {
|
|
24
|
+
return true;
|
|
25
|
+
} else if (l.startsWith("Found ")) {
|
|
26
|
+
return l.includes("error");
|
|
27
|
+
} else {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function make(watchdogMsOpt, cb) {
|
|
33
|
+
let watchdogMs = watchdogMsOpt !== undefined ? watchdogMsOpt : 120000;
|
|
34
|
+
let compiling = {
|
|
35
|
+
contents: false
|
|
36
|
+
};
|
|
37
|
+
let hasError = {
|
|
38
|
+
contents: false
|
|
39
|
+
};
|
|
40
|
+
let startTime = {
|
|
41
|
+
contents: 0.0
|
|
42
|
+
};
|
|
43
|
+
let buffer = {
|
|
44
|
+
contents: []
|
|
45
|
+
};
|
|
46
|
+
let timer = {
|
|
47
|
+
contents: undefined
|
|
48
|
+
};
|
|
49
|
+
let watchdog = {
|
|
50
|
+
contents: undefined
|
|
51
|
+
};
|
|
52
|
+
let clearTimer = () => {
|
|
53
|
+
let t = timer.contents;
|
|
54
|
+
if (t !== undefined) {
|
|
55
|
+
clearTimeout(t);
|
|
56
|
+
timer.contents = undefined;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
let clearWatchdog = () => {
|
|
61
|
+
let t = watchdog.contents;
|
|
62
|
+
if (t !== undefined) {
|
|
63
|
+
clearTimeout(t);
|
|
64
|
+
watchdog.contents = undefined;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
let reset = () => {
|
|
69
|
+
compiling.contents = false;
|
|
70
|
+
hasError.contents = false;
|
|
71
|
+
buffer.contents = [];
|
|
72
|
+
};
|
|
73
|
+
let settle = () => {
|
|
74
|
+
if (!(compiling.contents && hasError.contents)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let msg = buffer.contents.slice(0, 20).join("\n");
|
|
78
|
+
clearWatchdog();
|
|
79
|
+
cb.onFail(msg);
|
|
80
|
+
reset();
|
|
81
|
+
};
|
|
82
|
+
let arm = () => {
|
|
83
|
+
clearTimer();
|
|
84
|
+
timer.contents = setTimeout(settle, 400);
|
|
85
|
+
};
|
|
86
|
+
let armWatchdog = () => {
|
|
87
|
+
clearWatchdog();
|
|
88
|
+
watchdog.contents = setTimeout(() => {
|
|
89
|
+
if (compiling.contents) {
|
|
90
|
+
clearTimer();
|
|
91
|
+
cb.onFail("build watchdog: no completion within " + (watchdogMs / 1000 | 0).toString() + "s");
|
|
92
|
+
return reset();
|
|
93
|
+
}
|
|
94
|
+
}, watchdogMs);
|
|
95
|
+
};
|
|
96
|
+
return line => {
|
|
97
|
+
let l = stripAnsi(line).trim();
|
|
98
|
+
if (isStartLine(l)) {
|
|
99
|
+
if (!compiling.contents) {
|
|
100
|
+
cb.onStart();
|
|
101
|
+
}
|
|
102
|
+
compiling.contents = true;
|
|
103
|
+
hasError.contents = false;
|
|
104
|
+
buffer.contents = [];
|
|
105
|
+
startTime.contents = performance.now();
|
|
106
|
+
arm();
|
|
107
|
+
return armWatchdog();
|
|
108
|
+
} else if (isFinishLine(l)) {
|
|
109
|
+
clearTimer();
|
|
110
|
+
clearWatchdog();
|
|
111
|
+
if (compiling.contents) {
|
|
112
|
+
cb.onOk(performance.now() - startTime.contents);
|
|
113
|
+
return reset();
|
|
114
|
+
} else {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
if (l.length > 0) {
|
|
119
|
+
buffer.contents = buffer.contents.concat([l]);
|
|
120
|
+
}
|
|
121
|
+
if (isErrorMarker(l)) {
|
|
122
|
+
hasError.contents = true;
|
|
123
|
+
}
|
|
124
|
+
return arm();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
stripAnsi,
|
|
131
|
+
isStartLine,
|
|
132
|
+
isFinishLine,
|
|
133
|
+
isErrorMarker,
|
|
134
|
+
make,
|
|
135
|
+
}
|
|
136
|
+
/* No side effect */
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// SIGINT / SIGTERM trap. Sets a module-level flag that the main loop
|
|
2
|
+
// polls between tests. The VS Code and JSON streaming formatters flush a
|
|
3
|
+
// `runEnd` event with the skipped remainder before the process exits.
|
|
4
|
+
|
|
5
|
+
type process
|
|
6
|
+
@val external process: process = "process"
|
|
7
|
+
@send external onSignal: (process, string, unit => unit) => unit = "on"
|
|
8
|
+
@send external exit: (process, int) => unit = "exit"
|
|
9
|
+
|
|
10
|
+
let cancelled = ref(false)
|
|
11
|
+
let handlers: ref<array<unit => unit>> = ref([])
|
|
12
|
+
|
|
13
|
+
let isCancelled = () => cancelled.contents
|
|
14
|
+
|
|
15
|
+
let onCancel = (handler: unit => unit) =>
|
|
16
|
+
handlers := Array.concat(handlers.contents, [handler])
|
|
17
|
+
|
|
18
|
+
let install = () => {
|
|
19
|
+
let handler = () => {
|
|
20
|
+
if !cancelled.contents {
|
|
21
|
+
cancelled := true
|
|
22
|
+
handlers.contents->Array.forEach(h =>
|
|
23
|
+
try h() catch {
|
|
24
|
+
| _ => ()
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
process->onSignal("SIGINT", handler)
|
|
30
|
+
process->onSignal("SIGTERM", handler)
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
let cancelled = {
|
|
5
|
+
contents: false
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
let handlers = {
|
|
9
|
+
contents: []
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function isCancelled() {
|
|
13
|
+
return cancelled.contents;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function onCancel(handler) {
|
|
17
|
+
handlers.contents = handlers.contents.concat([handler]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function install() {
|
|
21
|
+
let handler = () => {
|
|
22
|
+
if (!cancelled.contents) {
|
|
23
|
+
cancelled.contents = true;
|
|
24
|
+
handlers.contents.forEach(h => {
|
|
25
|
+
try {
|
|
26
|
+
return h();
|
|
27
|
+
} catch (exn) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
process.on("SIGINT", handler);
|
|
35
|
+
process.on("SIGTERM", handler);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
cancelled,
|
|
40
|
+
handlers,
|
|
41
|
+
isCancelled,
|
|
42
|
+
onCancel,
|
|
43
|
+
install,
|
|
44
|
+
}
|
|
45
|
+
/* No side effect */
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Minimal `node:child_process` binding for the watch-mode build manager. The
|
|
2
|
+
// only consumer is ProcessManager, which spawns one `pnpm run start`
|
|
3
|
+
// (`rescript build -w`) per package. Children are spawned **detached** so each
|
|
4
|
+
// gets its own process group; killing the negative pid then tears down the whole
|
|
5
|
+
// tree (pnpm + the rescript watcher it spawns) — no orphaned compilers.
|
|
6
|
+
|
|
7
|
+
type t
|
|
8
|
+
type stream
|
|
9
|
+
|
|
10
|
+
type spawnOptions = {
|
|
11
|
+
cwd: string,
|
|
12
|
+
detached: bool,
|
|
13
|
+
env: Dict.t<string>,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@module("node:child_process")
|
|
17
|
+
external _spawn: (string, array<string>, spawnOptions) => t = "spawn"
|
|
18
|
+
|
|
19
|
+
@val external _processEnv: Dict.t<string> = "process.env"
|
|
20
|
+
|
|
21
|
+
// Merge the current process env with optional overrides into a fresh dict — node's
|
|
22
|
+
// `spawn` replaces the whole env, so callers that pass `~env` still inherit PATH etc.
|
|
23
|
+
let mergeEnv = (overrides: option<Dict.t<string>>): Dict.t<string> => {
|
|
24
|
+
let m = Dict.make()
|
|
25
|
+
_processEnv->Dict.toArray->Array.forEach(((k, v)) => m->Dict.set(k, v))
|
|
26
|
+
switch overrides {
|
|
27
|
+
| Some(o) => o->Dict.toArray->Array.forEach(((k, v)) => m->Dict.set(k, v))
|
|
28
|
+
| None => ()
|
|
29
|
+
}
|
|
30
|
+
m
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@get external _pid: t => Nullable.t<int> = "pid"
|
|
34
|
+
@get external _stdout: t => stream = "stdout"
|
|
35
|
+
@get external _stderr: t => stream = "stderr"
|
|
36
|
+
@send external _streamSetEncoding: (stream, string) => unit = "setEncoding"
|
|
37
|
+
@send external _streamOn: (stream, string, string => unit) => unit = "on"
|
|
38
|
+
@send external _procOnClose: (t, string, Nullable.t<int> => unit) => unit = "on"
|
|
39
|
+
@send external _kill: (t, string) => bool = "kill"
|
|
40
|
+
@val external _processKill: (int, string) => unit = "process.kill"
|
|
41
|
+
|
|
42
|
+
let spawn = (cmd: string, args: array<string>, ~cwd: string, ~env: option<Dict.t<string>>=?): t =>
|
|
43
|
+
_spawn(cmd, args, {cwd, detached: true, env: mergeEnv(env)})
|
|
44
|
+
|
|
45
|
+
let pid = (proc: t): option<int> => proc->_pid->Nullable.toOption
|
|
46
|
+
|
|
47
|
+
// Subscribe to a stream line-by-line (stdout or stderr), buffering partial
|
|
48
|
+
// chunks. Used to classify ReScript compiler markers in Phase 5.
|
|
49
|
+
let onLines = (s: stream, cb: string => unit): unit => {
|
|
50
|
+
_streamSetEncoding(s, "utf8")
|
|
51
|
+
let buf = ref("")
|
|
52
|
+
_streamOn(s, "data", chunk => {
|
|
53
|
+
buf := buf.contents ++ chunk
|
|
54
|
+
let rec drain = () =>
|
|
55
|
+
switch String.indexOf(buf.contents, "\n") {
|
|
56
|
+
| -1 => ()
|
|
57
|
+
| idx => {
|
|
58
|
+
let line = String.slice(buf.contents, ~start=0, ~end=idx)
|
|
59
|
+
buf := String.slice(buf.contents, ~start=idx + 1, ~end=String.length(buf.contents))
|
|
60
|
+
cb(line)
|
|
61
|
+
drain()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
drain()
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let onStdoutLine = (proc: t, cb: string => unit): unit => onLines(proc->_stdout, cb)
|
|
69
|
+
let onStderrLine = (proc: t, cb: string => unit): unit => onLines(proc->_stderr, cb)
|
|
70
|
+
let onClose = (proc: t, cb: option<int> => unit): unit =>
|
|
71
|
+
_procOnClose(proc, "close", code => cb(code->Nullable.toOption))
|
|
72
|
+
|
|
73
|
+
// Kill the child's whole process group (negative pid) so the rescript watcher
|
|
74
|
+
// pnpm spawned dies too. Falls back to a direct kill if the pid is gone.
|
|
75
|
+
let killTree = (proc: t, signal: string): unit =>
|
|
76
|
+
switch proc->pid {
|
|
77
|
+
| Some(p) =>
|
|
78
|
+
try {
|
|
79
|
+
_processKill(-p, signal)
|
|
80
|
+
} catch {
|
|
81
|
+
| _ => ignore(proc->_kill(signal))
|
|
82
|
+
}
|
|
83
|
+
| None => ignore(proc->_kill(signal))
|
|
84
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
4
|
+
import * as Nodechild_process from "node:child_process";
|
|
5
|
+
|
|
6
|
+
function mergeEnv(overrides) {
|
|
7
|
+
let m = {};
|
|
8
|
+
Object.entries(process.env).forEach(param => {
|
|
9
|
+
m[param[0]] = param[1];
|
|
10
|
+
});
|
|
11
|
+
if (overrides !== undefined) {
|
|
12
|
+
Object.entries(overrides).forEach(param => {
|
|
13
|
+
m[param[0]] = param[1];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return m;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function spawn(cmd, args, cwd, env) {
|
|
20
|
+
return Nodechild_process.spawn(cmd, args, {
|
|
21
|
+
cwd: cwd,
|
|
22
|
+
detached: true,
|
|
23
|
+
env: mergeEnv(env)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function pid(proc) {
|
|
28
|
+
return Primitive_option.fromNullable(proc.pid);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function onLines(s, cb) {
|
|
32
|
+
s.setEncoding("utf8");
|
|
33
|
+
let buf = {
|
|
34
|
+
contents: ""
|
|
35
|
+
};
|
|
36
|
+
s.on("data", chunk => {
|
|
37
|
+
buf.contents = buf.contents + chunk;
|
|
38
|
+
let drain = () => {
|
|
39
|
+
while (true) {
|
|
40
|
+
let idx = buf.contents.indexOf("\n");
|
|
41
|
+
if (idx === -1) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let line = buf.contents.slice(0, idx);
|
|
45
|
+
buf.contents = buf.contents.slice(idx + 1 | 0, buf.contents.length);
|
|
46
|
+
cb(line);
|
|
47
|
+
continue;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
drain();
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onStdoutLine(proc, cb) {
|
|
55
|
+
onLines(proc.stdout, cb);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function onStderrLine(proc, cb) {
|
|
59
|
+
onLines(proc.stderr, cb);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function onClose(proc, cb) {
|
|
63
|
+
proc.on("close", code => cb((code == null) ? undefined : Primitive_option.some(code)));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function killTree(proc, signal) {
|
|
67
|
+
let p = Primitive_option.fromNullable(proc.pid);
|
|
68
|
+
if (p !== undefined) {
|
|
69
|
+
try {
|
|
70
|
+
process.kill(-p | 0, signal);
|
|
71
|
+
return;
|
|
72
|
+
} catch (exn) {
|
|
73
|
+
proc.kill(signal);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
proc.kill(signal);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
mergeEnv,
|
|
84
|
+
spawn,
|
|
85
|
+
pid,
|
|
86
|
+
onLines,
|
|
87
|
+
onStdoutLine,
|
|
88
|
+
onStderrLine,
|
|
89
|
+
onClose,
|
|
90
|
+
killTree,
|
|
91
|
+
}
|
|
92
|
+
/* node:child_process Not a pure module */
|