@deeeed/metamask-harness 0.26.2 → 0.26.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.
package/CHANGELOG.md
CHANGED
package/dist/commands/stop.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { color } from "../cli-color.js";
|
|
2
2
|
import { getAdapterSurface } from "../adapters/surface.js";
|
|
3
3
|
import { usageOut } from "./shared.js";
|
|
4
|
+
import { stopProjectCollector } from "../../library/actions/shared/analytics/collector.mjs";
|
|
4
5
|
import {
|
|
5
6
|
parseArgs,
|
|
6
7
|
optionFlag,
|
|
@@ -23,6 +24,9 @@ async function handleStop(argv) {
|
|
|
23
24
|
if (stop.kind === "headless") {
|
|
24
25
|
return usageOut(json, "stop", stop.message, stop.userAction);
|
|
25
26
|
}
|
|
27
|
+
const collector = await stopProjectCollector(target);
|
|
28
|
+
const signalled = (stop.signalled ?? 0) + (collector.stopped ? 1 : 0);
|
|
29
|
+
const summary = collector.stopped ? `${stop.summary}; stopped analytics collector ${collector.pid}` : stop.summary;
|
|
26
30
|
const next = adapter === "extension" ? `${surface.hints.launch} --target ${shellQuote(target)}` : void 0;
|
|
27
31
|
const userAction = `mm-harness status --target ${shellQuote(target)} --json`;
|
|
28
32
|
if (json) {
|
|
@@ -34,10 +38,10 @@ async function handleStop(argv) {
|
|
|
34
38
|
adapter,
|
|
35
39
|
target,
|
|
36
40
|
status: stop.status === 0 ? "pass" : "fail",
|
|
37
|
-
...stop.signalled !== void 0 ? { signalled
|
|
41
|
+
...stop.signalled !== void 0 || collector.stopped ? { signalled } : {},
|
|
38
42
|
exitCode: stop.status,
|
|
39
43
|
...stop.output ? { output: stop.output } : {},
|
|
40
|
-
...stop.status === 0 ? next ? { next } : {} : { error: { code: "DEV_SERVER_STOP_FAILED", message:
|
|
44
|
+
...stop.status === 0 ? next ? { next } : {} : { error: { code: "DEV_SERVER_STOP_FAILED", message: summary, userAction } }
|
|
41
45
|
},
|
|
42
46
|
null,
|
|
43
47
|
2
|
|
@@ -46,7 +50,7 @@ async function handleStop(argv) {
|
|
|
46
50
|
} else {
|
|
47
51
|
if (stop.output) process.stderr.write(`${stop.output}
|
|
48
52
|
`);
|
|
49
|
-
console.error(`${color(stop.status === 0 ? "ok" : "err", stop.status === 0 ? "\u2713" : "\u2717")} ${
|
|
53
|
+
console.error(`${color(stop.status === 0 ? "ok" : "err", stop.status === 0 ? "\u2713" : "\u2717")} ${summary}`);
|
|
50
54
|
if (stop.status !== 0 || next) console.error(` Next: ${stop.status === 0 ? next : userAction}`);
|
|
51
55
|
}
|
|
52
56
|
return stop.status;
|
|
@@ -268,6 +268,22 @@ async function stopCollector(state) {
|
|
|
268
268
|
return true;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
export async function stopProjectCollector(projectRoot) {
|
|
272
|
+
const { stateFile } = collectorPaths(projectRoot);
|
|
273
|
+
const state = await readState(stateFile);
|
|
274
|
+
if (!state) return { stopped: false, pid: null };
|
|
275
|
+
|
|
276
|
+
const stopped = await stopCollector(state);
|
|
277
|
+
if (stopped || !pidAlive(state.pid)) {
|
|
278
|
+
try {
|
|
279
|
+
await unlink(stateFile);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (error?.code !== 'ENOENT') throw error;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return { stopped, pid: stopped ? state.pid : null };
|
|
285
|
+
}
|
|
286
|
+
|
|
271
287
|
async function stopSpawnedCollector(pid) {
|
|
272
288
|
if (!pidAlive(pid)) return;
|
|
273
289
|
try {
|