qunitx-cli 0.6.0 → 0.8.0
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/deno.lock
CHANGED
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
"npm:@types/picomatch@*": "4.0.2",
|
|
7
7
|
"npm:@types/ws@*": "8.18.1",
|
|
8
8
|
"npm:cheerio@*": "1.2.0",
|
|
9
|
-
"npm:cheerio@^1.2.0": "1.2.0",
|
|
10
9
|
"npm:chokidar@*": "5.0.0",
|
|
11
|
-
"npm:chokidar@5": "5.0.0",
|
|
12
10
|
"npm:cors@^2.8.6": "2.8.6",
|
|
13
11
|
"npm:esbuild@*": "0.27.4",
|
|
14
12
|
"npm:esbuild@~0.27.3": "0.27.4",
|
|
@@ -1324,8 +1322,6 @@
|
|
|
1324
1322
|
],
|
|
1325
1323
|
"packageJson": {
|
|
1326
1324
|
"dependencies": [
|
|
1327
|
-
"npm:cheerio@^1.2.0",
|
|
1328
|
-
"npm:chokidar@5",
|
|
1329
1325
|
"npm:cors@^2.8.6",
|
|
1330
1326
|
"npm:esbuild@~0.27.3",
|
|
1331
1327
|
"npm:express@^5.2.1",
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { stat } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
2
4
|
import { green, magenta, red, yellow } from '../utils/color.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
* Starts
|
|
7
|
+
* Starts `fs.watch` watchers for each lookup path and calls `onEventFunc` on JS/TS file changes, debounced via a flag.
|
|
8
|
+
* Uses `config.fsTree` to distinguish `unlink` (tracked file) from `unlinkDir` (directory) on deletion.
|
|
6
9
|
* @returns {object}
|
|
7
10
|
*/
|
|
8
11
|
export default function setupFileWatchers(testFileLookupPaths, config, onEventFunc, onFinishFunc) {
|
|
9
12
|
const extensions = config.extensions || ['js', 'ts'];
|
|
10
|
-
const fileWatchers = testFileLookupPaths.reduce((
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
13
|
+
const fileWatchers = testFileLookupPaths.reduce((watchers, watchPath) => {
|
|
14
|
+
let ready = false;
|
|
15
|
+
const watcher = fs.watch(watchPath, { recursive: true }, async (eventType, filename) => {
|
|
16
|
+
if (!ready || !filename) return;
|
|
17
|
+
const fullPath = path.join(watchPath, filename);
|
|
18
|
+
if (eventType === 'change') {
|
|
19
|
+
return handleWatchEvent(config, extensions, 'change', fullPath, onEventFunc, onFinishFunc);
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const s = await stat(fullPath);
|
|
23
|
+
handleWatchEvent(
|
|
24
|
+
config,
|
|
25
|
+
extensions,
|
|
26
|
+
s.isDirectory() ? 'addDir' : 'add',
|
|
27
|
+
fullPath,
|
|
28
|
+
onEventFunc,
|
|
29
|
+
onFinishFunc,
|
|
30
|
+
);
|
|
31
|
+
} catch {
|
|
32
|
+
const event = config.fsTree && fullPath in config.fsTree ? 'unlink' : 'unlinkDir';
|
|
33
|
+
handleWatchEvent(config, extensions, event, fullPath, onEventFunc, onFinishFunc);
|
|
34
|
+
}
|
|
17
35
|
});
|
|
36
|
+
setImmediate(() => {
|
|
37
|
+
ready = true;
|
|
38
|
+
});
|
|
39
|
+
return Object.assign(watchers, { [watchPath]: watcher });
|
|
18
40
|
}, {});
|
|
19
41
|
|
|
20
42
|
return {
|
|
@@ -28,7 +50,7 @@ export default function setupFileWatchers(testFileLookupPaths, config, onEventFu
|
|
|
28
50
|
}
|
|
29
51
|
|
|
30
52
|
/**
|
|
31
|
-
* Routes a
|
|
53
|
+
* Routes a file-system event to fsTree mutation and optional rebuild trigger.
|
|
32
54
|
* `unlinkDir` bypasses the extension filter so deleted directories always clean up fsTree.
|
|
33
55
|
* @returns {void}
|
|
34
56
|
*/
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
1
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z]+:)?\/\//i;
|
|
2
|
+
const SCRIPT_SRC_REGEX = /<script[^>]+\bsrc=['"]([^'"]+)['"]/gi;
|
|
3
|
+
const LINK_HREF_REGEX = /<link[^>]+\bhref=['"]([^'"]+)['"]/gi;
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Parses an HTML string and returns all internal (non-absolute-URL) `<script src>` and `<link href>` paths.
|
|
7
7
|
* @returns {string[]}
|
|
8
8
|
*/
|
|
9
9
|
export default function findInternalAssetsFromHTML(htmlContent) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
.toArray()
|
|
13
|
-
.map((scriptNode) => $(scriptNode).attr('src'))
|
|
10
|
+
const links = [...htmlContent.matchAll(LINK_HREF_REGEX)]
|
|
11
|
+
.map((m) => m[1])
|
|
14
12
|
.filter((uri) => !ABSOLUTE_URL_REGEX.test(uri));
|
|
15
|
-
const
|
|
16
|
-
.
|
|
17
|
-
.map((scriptNode) => $(scriptNode).attr('href'))
|
|
13
|
+
const scripts = [...htmlContent.matchAll(SCRIPT_SRC_REGEX)]
|
|
14
|
+
.map((m) => m[1])
|
|
18
15
|
.filter((uri) => !ABSOLUTE_URL_REGEX.test(uri));
|
|
19
16
|
|
|
20
|
-
return
|
|
21
|
-
// TODO: maybe needs normalization ? .map((fileReferencePath) => fileReferencePath.replace('/assets', `${projectRoot}/tmp/assets`));
|
|
17
|
+
return links.concat(scripts);
|
|
22
18
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qunitx-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
|
|
6
6
|
"main": "cli.js",
|
|
7
7
|
"author": "Izel Nakri",
|
|
@@ -43,8 +43,6 @@
|
|
|
43
43
|
"url": "https://github.com/izelnakri/qunitx-cli.git"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"cheerio": "^1.2.0",
|
|
47
|
-
"chokidar": "^5.0.0",
|
|
48
46
|
"esbuild": "^0.27.3",
|
|
49
47
|
"picomatch": "^4.0.3",
|
|
50
48
|
"puppeteer": "^24.38.0",
|