qunitx-cli 0.34.0 → 0.34.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/qunitx.js CHANGED
@@ -8,6 +8,7 @@ import { spawn } from 'node:child_process';
8
8
  import { access, constants, readFile } from 'node:fs/promises';
9
9
  import { fileURLToPath } from 'node:url';
10
10
  import { dirname, join } from 'node:path';
11
+ import { canUseSea } from './sea-support.js';
11
12
 
12
13
  // Turn on V8's on-disk compile cache before importing dist/cli.js — caches
13
14
  // the bundle + its external deps (esbuild, playwright-core, ws) across cold
@@ -53,7 +54,7 @@ const platformMap = {
53
54
  const target = platformMap[`${process.platform}-${process.arch}`];
54
55
 
55
56
  async function trySeaBinary() {
56
- if (!target) return false;
57
+ if (!target || !canUseSea(process.cwd())) return false;
57
58
  try {
58
59
  const pkgJsonPath = require.resolve(`${target.seaPkg}/package.json`);
59
60
  const seaVersion = JSON.parse(await readFile(pkgJsonPath, 'utf8')).version;
@@ -0,0 +1,37 @@
1
+ import { createRequire } from 'node:module';
2
+ import { join } from 'node:path';
3
+
4
+ // esbuild, playwright-core and ws are `external` in the dist bundle, so the SEA carries the
5
+ // import statements but not the packages.
6
+ export const SEA_EXTERNALS = ['playwright-core', 'esbuild', 'ws'];
7
+
8
+ /**
9
+ * Whether a Node SEA launched in `cwd` would be able to load the runner's external dependencies.
10
+ *
11
+ * A SEA has no path of its own, so Node resolves the bundle's bare specifiers against the current
12
+ * directory instead of against the installation. When qunitx is installed globally and run in a
13
+ * project that does not itself depend on it, nothing answers them and the run dies on the first
14
+ * one it reaches — `Cannot find package 'playwright-core' imported from <cwd>`. The bundle's
15
+ * imports are static, so there is nothing to redirect at runtime; the only honest question is
16
+ * whether this directory can satisfy them at all.
17
+ *
18
+ * Own file, and exported, because it is the whole of the decision and the bin script cannot be
19
+ * imported to test it — importing it runs the CLI.
20
+ *
21
+ * ```js
22
+ * canUseSea('/tmp/a-project-with-no-node-modules'); // false — fall back to dist/cli.js
23
+ * ```
24
+ */
25
+ export function canUseSea(cwd) {
26
+ // A file inside `cwd`, because createRequire resolves relative to a *module*, not a directory.
27
+ const fromCwd = createRequire(join(cwd, 'noop.js'));
28
+
29
+ return SEA_EXTERNALS.every((name) => {
30
+ try {
31
+ fromCwd.resolve(name);
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ });
37
+ }
package/dist/cli.js CHANGED
@@ -1742,7 +1742,7 @@ var init_package = __esm({
1742
1742
  package_default = {
1743
1743
  name: "qunitx-cli",
1744
1744
  type: "module",
1745
- version: "0.34.0",
1745
+ version: "0.34.1",
1746
1746
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
1747
1747
  author: "Izel Nakri",
1748
1748
  license: "MIT",
package/dist/index.js CHANGED
@@ -10312,7 +10312,7 @@ import path26 from "node:path";
10312
10312
  var package_default = {
10313
10313
  name: "qunitx-cli",
10314
10314
  type: "module",
10315
- version: "0.34.0",
10315
+ version: "0.34.1",
10316
10316
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
10317
10317
  author: "Izel Nakri",
10318
10318
  license: "MIT",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx-cli",
3
3
  "type": "module",
4
- "version": "0.34.0",
4
+ "version": "0.34.1",
5
5
  "description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",