fireemu 0.7.0 → 0.7.1
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/bin/fireemu.mjs +32 -16
- package/package.json +6 -6
package/bin/fireemu.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// The `fireemu` launcher: find the binary for this platform and
|
|
2
|
+
// The `fireemu` launcher: find the binary for this platform and supervise it.
|
|
3
3
|
//
|
|
4
4
|
// `fireemu` itself carries no binary. Each platform's daemon ships in its own package
|
|
5
5
|
// (`@fireemu/darwin-arm64` and friends), declared here as an optional dependency with an `os`
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// `package.json` rather than hard-coded, so it always names the platforms that were actually
|
|
12
12
|
// published beside this launcher.
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { spawn } from "node:child_process";
|
|
15
15
|
import { chmodSync, accessSync, constants as fsConstants, readFileSync } from "node:fs";
|
|
16
16
|
import { createRequire } from "node:module";
|
|
17
17
|
import { constants as osConstants } from "node:os";
|
|
@@ -114,27 +114,43 @@ function main() {
|
|
|
114
114
|
process.exit(1);
|
|
115
115
|
}
|
|
116
116
|
ensureExecutable(binary.path);
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
const
|
|
117
|
+
// Keep terminal I/O and the foreground process group intact. PID-directed signals only
|
|
118
|
+
// reach this launcher, so forward them and wait for the daemon's own shutdown to finish.
|
|
119
|
+
const child = spawn(binary.path, process.argv.slice(2), {
|
|
120
120
|
stdio: "inherit",
|
|
121
121
|
windowsHide: false,
|
|
122
122
|
});
|
|
123
|
-
|
|
123
|
+
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
124
|
+
process.on(signal, () => {
|
|
125
|
+
// Windows delivers console Ctrl-C to the child directly; child.kill would forcefully
|
|
126
|
+
// terminate it instead of requesting graceful shutdown. Only wait on that platform.
|
|
127
|
+
if (process.platform === "win32") return;
|
|
128
|
+
// Do not use child.killed here: it means a signal was sent, not that the child exited.
|
|
129
|
+
if (child.exitCode === null && child.signalCode === null) child.kill(signal);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
child.on("error", (error) => {
|
|
133
|
+
if (child.pid) {
|
|
134
|
+
// A failed signal delivery must not orphan a daemon that is still running.
|
|
135
|
+
process.stderr.write(`fireemu could not signal the daemon: ${error.message}\n`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
124
138
|
const reason =
|
|
125
|
-
|
|
139
|
+
error.code === "ENOENT"
|
|
126
140
|
? `${binary.path} does not exist (from ${binary.from})`
|
|
127
|
-
: `${binary.path}: ${
|
|
141
|
+
: `${binary.path}: ${error.message}`;
|
|
128
142
|
process.stderr.write(`fireemu could not start the daemon: ${reason}\n`);
|
|
129
143
|
process.exit(1);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
});
|
|
145
|
+
child.on("exit", (code, signal) => {
|
|
146
|
+
if (signal) {
|
|
147
|
+
// Report the death the way a shell does, so `fireemu ... ; echo $?` matches running the
|
|
148
|
+
// daemon directly.
|
|
149
|
+
const number = osConstants.signals[signal] ?? 0;
|
|
150
|
+
process.exit(128 + number);
|
|
151
|
+
}
|
|
152
|
+
process.exit(code ?? 1);
|
|
153
|
+
});
|
|
138
154
|
}
|
|
139
155
|
|
|
140
156
|
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fireemu",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "An experimental local runtime for testing Firebase SDK and Functions code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"emulator",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
],
|
|
28
28
|
"type": "module",
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@fireemu/darwin-arm64": "0.7.
|
|
31
|
-
"@fireemu/darwin-x64": "0.7.
|
|
32
|
-
"@fireemu/linux-x64": "0.7.
|
|
33
|
-
"@fireemu/linux-arm64": "0.7.
|
|
34
|
-
"@fireemu/win32-x64": "0.7.
|
|
30
|
+
"@fireemu/darwin-arm64": "0.7.1",
|
|
31
|
+
"@fireemu/darwin-x64": "0.7.1",
|
|
32
|
+
"@fireemu/linux-x64": "0.7.1",
|
|
33
|
+
"@fireemu/linux-arm64": "0.7.1",
|
|
34
|
+
"@fireemu/win32-x64": "0.7.1"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=20"
|