@rstest/core 0.6.0 → 0.6.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/0~967.js DELETED
@@ -1,99 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- export const __webpack_id__ = "967";
4
- export const __webpack_ids__ = [
5
- "967"
6
- ];
7
- export const __webpack_modules__ = {
8
- "./src/core/restart.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
- __webpack_require__.d(__webpack_exports__, {
10
- onBeforeRestart: ()=>onBeforeRestart,
11
- watchFilesForRestart: ()=>watchFilesForRestart
12
- });
13
- var external_node_path_ = __webpack_require__("node:path");
14
- var commands = __webpack_require__("./src/cli/commands.ts");
15
- var utils = __webpack_require__("./src/utils/index.ts");
16
- const GLOB_REGEX = /[*?{}[\]()!@+|]/;
17
- const isGlob = (str)=>GLOB_REGEX.test(str);
18
- async function createChokidar(pathOrGlobs, root, options) {
19
- const chokidar = await Promise.all([
20
- __webpack_require__.e("928"),
21
- __webpack_require__.e("414")
22
- ]).then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
23
- const watchFiles = new Set();
24
- const globPatterns = pathOrGlobs.filter((pathOrGlob)=>{
25
- if (isGlob(pathOrGlob)) return true;
26
- watchFiles.add(pathOrGlob);
27
- return false;
28
- });
29
- if (globPatterns.length) {
30
- const { glob } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/tinyglobby@0.2.15/node_modules/tinyglobby/dist/index.mjs"));
31
- const files = await glob(globPatterns, {
32
- cwd: root,
33
- absolute: true
34
- });
35
- for (const file of files)watchFiles.add(file);
36
- }
37
- return chokidar.watch(Array.from(watchFiles), options);
38
- }
39
- let cleaners = [];
40
- const onBeforeRestart = (cleaner)=>{
41
- cleaners.push(cleaner);
42
- };
43
- const clearConsole = ()=>{
44
- if ((0, utils.Un)() && !process.env.DEBUG) process.stdout.write('\x1B[H\x1B[2J');
45
- };
46
- const beforeRestart = async ({ filePath, root, clear = true })=>{
47
- if (clear) clearConsole();
48
- if (filePath) {
49
- const filename = external_node_path_["default"].relative(root, filePath);
50
- utils.vF.info(`restarting Rstest as ${utils.yW.yellow(filename)} changed\n`);
51
- } else utils.vF.info('restarting Rstest...\n');
52
- for (const cleaner of cleaners)await cleaner();
53
- cleaners = [];
54
- };
55
- const restart = async ({ filePath, clear = true, options, filters, root })=>{
56
- await beforeRestart({
57
- filePath,
58
- root,
59
- clear
60
- });
61
- await (0, commands.a)({
62
- options,
63
- filters,
64
- command: 'watch'
65
- });
66
- return true;
67
- };
68
- async function watchFilesForRestart({ rstest, watchOptions, options, filters }) {
69
- const configFilePaths = [
70
- rstest.context.configFilePath,
71
- ...rstest.context.projects.map((project)=>project.configFilePath)
72
- ].filter(Boolean);
73
- if (0 === configFilePaths.length) return;
74
- const root = rstest.context.rootPath;
75
- const watcher = await createChokidar(configFilePaths, root, {
76
- ignoreInitial: true,
77
- ignorePermissionErrors: true,
78
- ...watchOptions
79
- });
80
- let restarting = false;
81
- const onChange = async (filePath)=>{
82
- if (restarting) return;
83
- restarting = true;
84
- const restarted = await restart({
85
- options,
86
- root,
87
- filters,
88
- filePath
89
- });
90
- if (restarted) await watcher.close();
91
- else utils.vF.error('Restart failed');
92
- restarting = false;
93
- };
94
- watcher.on('add', onChange);
95
- watcher.on('change', onChange);
96
- watcher.on('unlink', onChange);
97
- }
98
- }
99
- };