qunitx-cli 0.34.1 → 0.34.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 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.1",
1745
+ version: "0.34.2",
1746
1746
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
1747
1747
  author: "Izel Nakri",
1748
1748
  license: "MIT",
@@ -7446,15 +7446,26 @@ async function writeOutputStaticFiles({ projectRoot, output }, htmlAssets) {
7446
7446
  const outDir = path22.resolve(projectRoot, output);
7447
7447
  const destPath = path22.join(outDir, assetRelativePath);
7448
7448
  await ensureFolderExists(destPath);
7449
- await fs17.copyFile(assetAbsolutePath, destPath);
7449
+ await copyAsset(assetAbsolutePath, destPath);
7450
7450
  });
7451
7451
  await Promise.all(staticHTMLPromises.concat(assetPromises));
7452
7452
  }
7453
7453
  async function ensureFolderExists(assetPath) {
7454
7454
  await fs17.mkdir(path22.dirname(assetPath), { recursive: true });
7455
7455
  }
7456
+ async function copyAsset(source, destination) {
7457
+ try {
7458
+ await fs17.copyFile(source, destination);
7459
+ } catch (error2) {
7460
+ if (error2.code !== "ENOENT") throw error2;
7461
+ else if (source.endsWith(path22.join("qunitx", "vendor", "qunit.css"))) {
7462
+ await fs17.writeFile(destination, await readTemplate("vendor/qunit.css"));
7463
+ }
7464
+ }
7465
+ }
7456
7466
  var init_write_output_static_files = __esm({
7457
7467
  "lib/setup/write-output-static-files.ts"() {
7468
+ init_read_template();
7458
7469
  }
7459
7470
  });
7460
7471
 
package/dist/index.js CHANGED
@@ -6114,15 +6114,26 @@ async function writeOutputStaticFiles({ projectRoot, output }, htmlAssets) {
6114
6114
  const outDir = path15.resolve(projectRoot, output);
6115
6115
  const destPath = path15.join(outDir, assetRelativePath);
6116
6116
  await ensureFolderExists(destPath);
6117
- await fs12.copyFile(assetAbsolutePath, destPath);
6117
+ await copyAsset(assetAbsolutePath, destPath);
6118
6118
  });
6119
6119
  await Promise.all(staticHTMLPromises.concat(assetPromises));
6120
6120
  }
6121
6121
  async function ensureFolderExists(assetPath) {
6122
6122
  await fs12.mkdir(path15.dirname(assetPath), { recursive: true });
6123
6123
  }
6124
+ async function copyAsset(source, destination) {
6125
+ try {
6126
+ await fs12.copyFile(source, destination);
6127
+ } catch (error2) {
6128
+ if (error2.code !== "ENOENT") throw error2;
6129
+ else if (source.endsWith(path15.join("qunitx", "vendor", "qunit.css"))) {
6130
+ await fs12.writeFile(destination, await readTemplate("vendor/qunit.css"));
6131
+ }
6132
+ }
6133
+ }
6124
6134
  var init_write_output_static_files = __esm({
6125
6135
  "lib/setup/write-output-static-files.ts"() {
6136
+ init_read_template();
6126
6137
  }
6127
6138
  });
6128
6139
 
@@ -10312,7 +10323,7 @@ import path26 from "node:path";
10312
10323
  var package_default = {
10313
10324
  name: "qunitx-cli",
10314
10325
  type: "module",
10315
- version: "0.34.1",
10326
+ version: "0.34.2",
10316
10327
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
10317
10328
  author: "Izel Nakri",
10318
10329
  license: "MIT",
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
+ import { readTemplate } from '../utils/read-template.ts';
3
4
  import type { HtmlAssets } from '../types.ts';
4
5
 
5
6
  /**
@@ -41,7 +42,7 @@ export async function writeOutputStaticFiles(
41
42
  const outDir = path.resolve(projectRoot, output);
42
43
  const destPath = path.join(outDir, assetRelativePath);
43
44
  await ensureFolderExists(destPath);
44
- await fs.copyFile(assetAbsolutePath, destPath);
45
+ await copyAsset(assetAbsolutePath, destPath);
45
46
  });
46
47
 
47
48
  await Promise.all(staticHTMLPromises.concat(assetPromises));
@@ -50,3 +51,26 @@ export async function writeOutputStaticFiles(
50
51
  async function ensureFolderExists(assetPath: string): Promise<void> {
51
52
  await fs.mkdir(path.dirname(assetPath), { recursive: true });
52
53
  }
54
+
55
+ /**
56
+ * Copies one referenced asset, tolerating a source that is not on disk.
57
+ *
58
+ * `qunitx init` writes a page that links `node_modules/qunitx/vendor/qunit.css`, which only exists
59
+ * when the project installed `qunitx` itself — a globally-installed CLI in a fresh project has no
60
+ * such file, and copying it blindly failed the whole run before any test could report. The server
61
+ * already answers that URL from the CLI's embedded copy; the static output now does the same.
62
+ *
63
+ * Any other missing asset is skipped rather than fatal. A page referencing a stylesheet that is not
64
+ * there renders unstyled, which is the page's problem; it is not a reason to fail the test run, and
65
+ * the server treats the same request as a 404 rather than an error.
66
+ */
67
+ async function copyAsset(source: string, destination: string): Promise<void> {
68
+ try {
69
+ await fs.copyFile(source, destination);
70
+ } catch (error) {
71
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
72
+ else if (source.endsWith(path.join('qunitx', 'vendor', 'qunit.css'))) {
73
+ await fs.writeFile(destination, await readTemplate('vendor/qunit.css'));
74
+ }
75
+ }
76
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx-cli",
3
3
  "type": "module",
4
- "version": "0.34.1",
4
+ "version": "0.34.2",
5
5
  "description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",