jev-test-filter 0.1.1 → 0.1.2
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/dist/cli.js +16 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
* Only this file writes to a stream or exits.
|
|
22
22
|
*/
|
|
23
23
|
import { spawn } from "node:child_process";
|
|
24
|
+
import { realpathSync } from "node:fs";
|
|
24
25
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
25
26
|
import { dirname, join } from "node:path";
|
|
27
|
+
import { fileURLToPath } from "node:url";
|
|
26
28
|
import { parseArgs } from "node:util";
|
|
27
29
|
import { displayName } from "./questions.js";
|
|
28
30
|
import { fullName } from "./filter.js";
|
|
@@ -310,10 +312,21 @@ async function main() {
|
|
|
310
312
|
process.stdout.write(`${renderLine(res)}\n`);
|
|
311
313
|
return stdoutExitCode(res);
|
|
312
314
|
}
|
|
315
|
+
/** Resolve npm's bin symlink before deciding whether this module is the entrypoint. */
|
|
316
|
+
function isCliInvocation(argv1, moduleUrl) {
|
|
317
|
+
if (!argv1)
|
|
318
|
+
return false;
|
|
319
|
+
try {
|
|
320
|
+
return realpathSync(argv1) === realpathSync(fileURLToPath(moduleUrl));
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
313
326
|
// Only run when invoked as a program, so the tests can import the renderers.
|
|
314
|
-
if (process.argv[1]
|
|
315
|
-
main().then((code) => process.
|
|
327
|
+
if (isCliInvocation(process.argv[1], import.meta.url)) {
|
|
328
|
+
main().then((code) => { process.exitCode = code; }, (err) => {
|
|
316
329
|
process.stderr.write(`jev-test-filter: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
317
|
-
process.
|
|
330
|
+
process.exitCode = 1;
|
|
318
331
|
});
|
|
319
332
|
}
|