@rstest/core 0.6.1 → 0.6.3
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/LICENSE.md +0 -14
- package/dist/0~171.js +4 -6
- package/dist/0~204.js +67 -77
- package/dist/0~263.js +1423 -0
- package/dist/0~350.js +29 -373
- package/dist/0~365.js +92 -0
- package/dist/0~463.js +331 -0
- package/dist/0~470.js +388 -0
- package/dist/0~607.js +119 -0
- package/dist/0~691.js +74 -82
- package/dist/0~711.js +29 -373
- package/dist/0~764.js +13284 -0
- package/dist/0~814.js +900 -0
- package/dist/0~830.js +1130 -0
- package/dist/0~836.js +13 -21
- package/dist/0~971.js +130 -136
- package/dist/597.js +174 -0
- package/dist/603.js +41 -0
- package/dist/808.js +167 -0
- package/dist/857.js +3252 -0
- package/dist/index.js +2394 -5972
- package/dist/rslib-runtime.js +60 -0
- package/dist/worker.js +154 -1393
- package/dist-types/index.d.ts +24 -3
- package/dist-types/worker.d.ts +8 -2
- package/package.json +2 -2
- package/dist/0~33.js +0 -425
- package/dist/0~414.js +0 -16
- package/dist/0~493.js +0 -126
- package/dist/0~603.js +0 -50
- package/dist/0~628.js +0 -1090
- package/dist/0~655.js +0 -11533
- package/dist/0~85.js +0 -1819
- package/dist/0~873.js +0 -1220
- package/dist/0~928.js +0 -1432
- package/dist/0~967.js +0 -99
- /package/dist/{0~928.js.LICENSE.txt → 0~263.js.LICENSE.txt} +0 -0
- /package/dist/{0~655.js.LICENSE.txt → 0~764.js.LICENSE.txt} +0 -0
package/dist/0~350.js
CHANGED
|
@@ -1,380 +1,36 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { checkPkgInstalled } from "./worker.js";
|
|
4
|
+
import { installGlobal, addDefaultErrorHandler } from "./0~463.js";
|
|
5
|
+
const environment = {
|
|
6
|
+
name: 'happy-dom',
|
|
7
|
+
async setup (global, { happyDom = {} }) {
|
|
8
|
+
checkPkgInstalled('happy-dom');
|
|
9
|
+
const { Window } = await import("happy-dom");
|
|
10
|
+
const win = new Window({
|
|
11
|
+
...happyDom,
|
|
12
|
+
url: happyDom.url || 'http://localhost:3000',
|
|
13
|
+
console: console && global.console ? global.console : void 0
|
|
11
14
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const win = new Window({
|
|
20
|
-
...happyDom,
|
|
21
|
-
url: happyDom.url || 'http://localhost:3000',
|
|
22
|
-
console: console && global.console ? global.console : void 0
|
|
23
|
-
});
|
|
24
|
-
const cleanupGlobal = (0, _utils__WEBPACK_IMPORTED_MODULE_1__.p5)(global, win, {
|
|
25
|
-
additionalKeys: [
|
|
26
|
-
'Request',
|
|
27
|
-
'Response',
|
|
28
|
-
'MessagePort',
|
|
29
|
-
'fetch'
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
const cleanupHandler = (0, _utils__WEBPACK_IMPORTED_MODULE_1__.d1)(global);
|
|
33
|
-
return {
|
|
34
|
-
async teardown () {
|
|
35
|
-
cleanupHandler();
|
|
36
|
-
if (win.close && win.happyDOM.abort) {
|
|
37
|
-
await win.happyDOM.abort();
|
|
38
|
-
win.close();
|
|
39
|
-
} else await win.happyDOM.cancelAsync();
|
|
40
|
-
cleanupGlobal();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
"./src/runtime/worker/env/utils.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
47
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
48
|
-
d1: ()=>addDefaultErrorHandler,
|
|
49
|
-
p5: ()=>installGlobal
|
|
15
|
+
const cleanupGlobal = installGlobal(global, win, {
|
|
16
|
+
additionalKeys: [
|
|
17
|
+
'Request',
|
|
18
|
+
'Response',
|
|
19
|
+
'MessagePort',
|
|
20
|
+
'fetch'
|
|
21
|
+
]
|
|
50
22
|
});
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
'DocumentFragment',
|
|
61
|
-
'DOMImplementation',
|
|
62
|
-
'Document',
|
|
63
|
-
'XMLDocument',
|
|
64
|
-
'CharacterData',
|
|
65
|
-
'Text',
|
|
66
|
-
'CDATASection',
|
|
67
|
-
'ProcessingInstruction',
|
|
68
|
-
'Comment',
|
|
69
|
-
'DocumentType',
|
|
70
|
-
'NodeList',
|
|
71
|
-
'RadioNodeList',
|
|
72
|
-
'HTMLCollection',
|
|
73
|
-
'HTMLOptionsCollection',
|
|
74
|
-
'DOMStringMap',
|
|
75
|
-
'DOMTokenList',
|
|
76
|
-
'StyleSheetList',
|
|
77
|
-
'HTMLElement',
|
|
78
|
-
'HTMLHeadElement',
|
|
79
|
-
'HTMLTitleElement',
|
|
80
|
-
'HTMLBaseElement',
|
|
81
|
-
'HTMLLinkElement',
|
|
82
|
-
'HTMLMetaElement',
|
|
83
|
-
'HTMLStyleElement',
|
|
84
|
-
'HTMLBodyElement',
|
|
85
|
-
'HTMLHeadingElement',
|
|
86
|
-
'HTMLParagraphElement',
|
|
87
|
-
'HTMLHRElement',
|
|
88
|
-
'HTMLPreElement',
|
|
89
|
-
'HTMLUListElement',
|
|
90
|
-
'HTMLOListElement',
|
|
91
|
-
'HTMLLIElement',
|
|
92
|
-
'HTMLMenuElement',
|
|
93
|
-
'HTMLDListElement',
|
|
94
|
-
'HTMLDivElement',
|
|
95
|
-
'HTMLAnchorElement',
|
|
96
|
-
'HTMLAreaElement',
|
|
97
|
-
'HTMLBRElement',
|
|
98
|
-
'HTMLButtonElement',
|
|
99
|
-
'HTMLCanvasElement',
|
|
100
|
-
'HTMLDataElement',
|
|
101
|
-
'HTMLDataListElement',
|
|
102
|
-
'HTMLDetailsElement',
|
|
103
|
-
'HTMLDialogElement',
|
|
104
|
-
'HTMLDirectoryElement',
|
|
105
|
-
'HTMLFieldSetElement',
|
|
106
|
-
'HTMLFontElement',
|
|
107
|
-
'HTMLFormElement',
|
|
108
|
-
'HTMLHtmlElement',
|
|
109
|
-
'HTMLImageElement',
|
|
110
|
-
'HTMLInputElement',
|
|
111
|
-
'HTMLLabelElement',
|
|
112
|
-
'HTMLLegendElement',
|
|
113
|
-
'HTMLMapElement',
|
|
114
|
-
'HTMLMarqueeElement',
|
|
115
|
-
'HTMLMediaElement',
|
|
116
|
-
'HTMLMeterElement',
|
|
117
|
-
'HTMLModElement',
|
|
118
|
-
'HTMLOptGroupElement',
|
|
119
|
-
'HTMLOptionElement',
|
|
120
|
-
'HTMLOutputElement',
|
|
121
|
-
'HTMLPictureElement',
|
|
122
|
-
'HTMLProgressElement',
|
|
123
|
-
'HTMLQuoteElement',
|
|
124
|
-
'HTMLScriptElement',
|
|
125
|
-
'HTMLSelectElement',
|
|
126
|
-
'HTMLSlotElement',
|
|
127
|
-
'HTMLSourceElement',
|
|
128
|
-
'HTMLSpanElement',
|
|
129
|
-
'HTMLTableCaptionElement',
|
|
130
|
-
'HTMLTableCellElement',
|
|
131
|
-
'HTMLTableColElement',
|
|
132
|
-
'HTMLTableElement',
|
|
133
|
-
'HTMLTimeElement',
|
|
134
|
-
'HTMLTableRowElement',
|
|
135
|
-
'HTMLTableSectionElement',
|
|
136
|
-
'HTMLTemplateElement',
|
|
137
|
-
'HTMLTextAreaElement',
|
|
138
|
-
'HTMLUnknownElement',
|
|
139
|
-
'HTMLFrameElement',
|
|
140
|
-
'HTMLFrameSetElement',
|
|
141
|
-
'HTMLIFrameElement',
|
|
142
|
-
'HTMLEmbedElement',
|
|
143
|
-
'HTMLObjectElement',
|
|
144
|
-
'HTMLParamElement',
|
|
145
|
-
'HTMLVideoElement',
|
|
146
|
-
'HTMLAudioElement',
|
|
147
|
-
'HTMLTrackElement',
|
|
148
|
-
'HTMLFormControlsCollection',
|
|
149
|
-
'SVGElement',
|
|
150
|
-
'SVGGraphicsElement',
|
|
151
|
-
'SVGSVGElement',
|
|
152
|
-
'SVGGElement',
|
|
153
|
-
'SVGDefsElement',
|
|
154
|
-
'SVGDescElement',
|
|
155
|
-
'SVGMetadataElement',
|
|
156
|
-
'SVGTitleElement',
|
|
157
|
-
'SVGSymbolElement',
|
|
158
|
-
'SVGSwitchElement',
|
|
159
|
-
'SVGAnimatedPreserveAspectRatio',
|
|
160
|
-
'SVGAnimatedRect',
|
|
161
|
-
'SVGAnimatedString',
|
|
162
|
-
'SVGNumber',
|
|
163
|
-
'SVGPreserveAspectRatio',
|
|
164
|
-
'SVGRect',
|
|
165
|
-
'SVGStringList',
|
|
166
|
-
'Event',
|
|
167
|
-
'BeforeUnloadEvent',
|
|
168
|
-
'BlobEvent',
|
|
169
|
-
'CloseEvent',
|
|
170
|
-
'CustomEvent',
|
|
171
|
-
'MessageEvent',
|
|
172
|
-
'ErrorEvent',
|
|
173
|
-
'HashChangeEvent',
|
|
174
|
-
'PopStateEvent',
|
|
175
|
-
'StorageEvent',
|
|
176
|
-
'ProgressEvent',
|
|
177
|
-
'PageTransitionEvent',
|
|
178
|
-
'SubmitEvent',
|
|
179
|
-
'UIEvent',
|
|
180
|
-
'FocusEvent',
|
|
181
|
-
'InputEvent',
|
|
182
|
-
'MouseEvent',
|
|
183
|
-
'KeyboardEvent',
|
|
184
|
-
'TouchEvent',
|
|
185
|
-
'CompositionEvent',
|
|
186
|
-
'WheelEvent',
|
|
187
|
-
'BarProp',
|
|
188
|
-
'External',
|
|
189
|
-
'Location',
|
|
190
|
-
'History',
|
|
191
|
-
'Screen',
|
|
192
|
-
'Performance',
|
|
193
|
-
'Navigator',
|
|
194
|
-
'Crypto',
|
|
195
|
-
'PluginArray',
|
|
196
|
-
'MimeTypeArray',
|
|
197
|
-
'Plugin',
|
|
198
|
-
'MimeType',
|
|
199
|
-
'FileReader',
|
|
200
|
-
'Blob',
|
|
201
|
-
'File',
|
|
202
|
-
'FileList',
|
|
203
|
-
'ValidityState',
|
|
204
|
-
'DOMParser',
|
|
205
|
-
'XMLSerializer',
|
|
206
|
-
'FormData',
|
|
207
|
-
'XMLHttpRequestEventTarget',
|
|
208
|
-
'XMLHttpRequestUpload',
|
|
209
|
-
'XMLHttpRequest',
|
|
210
|
-
'WebSocket',
|
|
211
|
-
'NodeFilter',
|
|
212
|
-
'NodeIterator',
|
|
213
|
-
'TreeWalker',
|
|
214
|
-
'AbstractRange',
|
|
215
|
-
'Range',
|
|
216
|
-
'StaticRange',
|
|
217
|
-
'Selection',
|
|
218
|
-
'Storage',
|
|
219
|
-
'CustomElementRegistry',
|
|
220
|
-
'ElementInternals',
|
|
221
|
-
'ShadowRoot',
|
|
222
|
-
'MutationObserver',
|
|
223
|
-
'MutationRecord',
|
|
224
|
-
'Headers',
|
|
225
|
-
'AbortController',
|
|
226
|
-
'AbortSignal',
|
|
227
|
-
'Uint8Array',
|
|
228
|
-
'Uint16Array',
|
|
229
|
-
'Uint32Array',
|
|
230
|
-
'Uint8ClampedArray',
|
|
231
|
-
'Int8Array',
|
|
232
|
-
'Int16Array',
|
|
233
|
-
'Int32Array',
|
|
234
|
-
'Float32Array',
|
|
235
|
-
'Float64Array',
|
|
236
|
-
'ArrayBuffer',
|
|
237
|
-
'DeviceMotionEventAcceleration',
|
|
238
|
-
'DeviceMotionEventRotationRate',
|
|
239
|
-
'DOMRectReadOnly',
|
|
240
|
-
'DOMRect',
|
|
241
|
-
'Image',
|
|
242
|
-
'Audio',
|
|
243
|
-
'Option',
|
|
244
|
-
'CSS'
|
|
245
|
-
];
|
|
246
|
-
const OTHER_KEYS = [
|
|
247
|
-
'addEventListener',
|
|
248
|
-
'alert',
|
|
249
|
-
'blur',
|
|
250
|
-
'cancelAnimationFrame',
|
|
251
|
-
'close',
|
|
252
|
-
'confirm',
|
|
253
|
-
'createPopup',
|
|
254
|
-
'dispatchEvent',
|
|
255
|
-
'document',
|
|
256
|
-
'focus',
|
|
257
|
-
'frames',
|
|
258
|
-
'getComputedStyle',
|
|
259
|
-
'history',
|
|
260
|
-
'innerHeight',
|
|
261
|
-
'innerWidth',
|
|
262
|
-
'length',
|
|
263
|
-
'location',
|
|
264
|
-
'matchMedia',
|
|
265
|
-
'moveBy',
|
|
266
|
-
'moveTo',
|
|
267
|
-
'name',
|
|
268
|
-
'navigator',
|
|
269
|
-
'open',
|
|
270
|
-
'outerHeight',
|
|
271
|
-
'outerWidth',
|
|
272
|
-
'pageXOffset',
|
|
273
|
-
'pageYOffset',
|
|
274
|
-
'parent',
|
|
275
|
-
'postMessage',
|
|
276
|
-
'print',
|
|
277
|
-
'prompt',
|
|
278
|
-
'removeEventListener',
|
|
279
|
-
'requestAnimationFrame',
|
|
280
|
-
'resizeBy',
|
|
281
|
-
'resizeTo',
|
|
282
|
-
'screen',
|
|
283
|
-
'screenLeft',
|
|
284
|
-
'screenTop',
|
|
285
|
-
'screenX',
|
|
286
|
-
'screenY',
|
|
287
|
-
'scroll',
|
|
288
|
-
'scrollBy',
|
|
289
|
-
'scrollLeft',
|
|
290
|
-
'scrollTo',
|
|
291
|
-
'scrollTop',
|
|
292
|
-
'scrollX',
|
|
293
|
-
'scrollY',
|
|
294
|
-
'self',
|
|
295
|
-
'stop',
|
|
296
|
-
'top',
|
|
297
|
-
'Window',
|
|
298
|
-
'window'
|
|
299
|
-
];
|
|
300
|
-
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
301
|
-
const SKIP_KEYS = [
|
|
302
|
-
'window',
|
|
303
|
-
'self',
|
|
304
|
-
'top',
|
|
305
|
-
'parent'
|
|
306
|
-
];
|
|
307
|
-
function getWindowKeys(global, win, additionalKeys = []) {
|
|
308
|
-
const keysArray = [
|
|
309
|
-
...additionalKeys,
|
|
310
|
-
...KEYS
|
|
311
|
-
];
|
|
312
|
-
return new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k)=>{
|
|
313
|
-
if (SKIP_KEYS.includes(k)) return false;
|
|
314
|
-
if (k in global) return keysArray.includes(k);
|
|
315
|
-
return true;
|
|
316
|
-
}));
|
|
317
|
-
}
|
|
318
|
-
function isClassLike(name) {
|
|
319
|
-
return name[0] === name[0]?.toUpperCase();
|
|
320
|
-
}
|
|
321
|
-
function installGlobal(global, win, options = {}) {
|
|
322
|
-
const { bindFunctions = true } = options || {};
|
|
323
|
-
const keys = getWindowKeys(global, win, options.additionalKeys);
|
|
324
|
-
const originals = new Map();
|
|
325
|
-
const overrides = new Map();
|
|
326
|
-
for (const key of keys){
|
|
327
|
-
const boundFunction = bindFunctions && 'function' == typeof win[key] && !isClassLike(key) && win[key].bind(win);
|
|
328
|
-
if (key in global) originals.set(key, global[key]);
|
|
329
|
-
Object.defineProperty(global, key, {
|
|
330
|
-
get () {
|
|
331
|
-
if (overrides.has(key)) return overrides.get(key);
|
|
332
|
-
if (boundFunction) return boundFunction;
|
|
333
|
-
return win[key];
|
|
334
|
-
},
|
|
335
|
-
set (v) {
|
|
336
|
-
overrides.set(key, v);
|
|
337
|
-
},
|
|
338
|
-
configurable: true
|
|
339
|
-
});
|
|
23
|
+
const cleanupHandler = addDefaultErrorHandler(global);
|
|
24
|
+
return {
|
|
25
|
+
async teardown () {
|
|
26
|
+
cleanupHandler();
|
|
27
|
+
if (win.close && win.happyDOM.abort) {
|
|
28
|
+
await win.happyDOM.abort();
|
|
29
|
+
win.close();
|
|
30
|
+
} else await win.happyDOM.cancelAsync();
|
|
31
|
+
cleanupGlobal();
|
|
340
32
|
}
|
|
341
|
-
|
|
342
|
-
global.self = global;
|
|
343
|
-
global.top = global;
|
|
344
|
-
global.parent = global;
|
|
345
|
-
if (global.global) global.global = global;
|
|
346
|
-
if (global.document?.defaultView) Object.defineProperty(global.document, 'defaultView', {
|
|
347
|
-
get: ()=>global,
|
|
348
|
-
enumerable: true,
|
|
349
|
-
configurable: true
|
|
350
|
-
});
|
|
351
|
-
for (const k of SKIP_KEYS)keys.add(k);
|
|
352
|
-
return ()=>{
|
|
353
|
-
for (const key of keys)delete global[key];
|
|
354
|
-
originals.forEach((v, k)=>{
|
|
355
|
-
global[k] = v;
|
|
356
|
-
});
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
function addDefaultErrorHandler(window) {
|
|
360
|
-
let userErrorListenerCount = 0;
|
|
361
|
-
const throwUnhandledError = (e)=>{
|
|
362
|
-
if (0 === userErrorListenerCount && null != e.error) process.emit('uncaughtException', e.error);
|
|
363
|
-
};
|
|
364
|
-
const addEventListener = window.addEventListener.bind(window);
|
|
365
|
-
const removeEventListener = window.removeEventListener.bind(window);
|
|
366
|
-
window.addEventListener('error', throwUnhandledError);
|
|
367
|
-
window.addEventListener = function(...args) {
|
|
368
|
-
if ('error' === args[0]) userErrorListenerCount++;
|
|
369
|
-
return addEventListener.apply(this, args);
|
|
370
|
-
};
|
|
371
|
-
window.removeEventListener = function(...args) {
|
|
372
|
-
if ('error' === args[0] && userErrorListenerCount) userErrorListenerCount--;
|
|
373
|
-
return removeEventListener.apply(this, args);
|
|
374
|
-
};
|
|
375
|
-
return ()=>{
|
|
376
|
-
window.removeEventListener('error', throwUnhandledError);
|
|
377
|
-
};
|
|
378
|
-
}
|
|
33
|
+
};
|
|
379
34
|
}
|
|
380
35
|
};
|
|
36
|
+
export { environment };
|
package/dist/0~365.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
+
import { src_logger, isTTY } from "./857.js";
|
|
5
|
+
import { runRest } from "./index.js";
|
|
6
|
+
const GLOB_REGEX = /[*?{}[\]()!@+|]/;
|
|
7
|
+
const isGlob = (str)=>GLOB_REGEX.test(str);
|
|
8
|
+
async function createChokidar(pathOrGlobs, root, options) {
|
|
9
|
+
const chokidar = await import("./0~263.js").then((mod)=>({
|
|
10
|
+
watch: mod.watch
|
|
11
|
+
}));
|
|
12
|
+
const watchFiles = new Set();
|
|
13
|
+
const globPatterns = pathOrGlobs.filter((pathOrGlob)=>{
|
|
14
|
+
if (isGlob(pathOrGlob)) return true;
|
|
15
|
+
watchFiles.add(pathOrGlob);
|
|
16
|
+
return false;
|
|
17
|
+
});
|
|
18
|
+
if (globPatterns.length) {
|
|
19
|
+
const { glob } = await import("./857.js").then((mod)=>({
|
|
20
|
+
glob: mod.glob
|
|
21
|
+
}));
|
|
22
|
+
const files = await glob(globPatterns, {
|
|
23
|
+
cwd: root,
|
|
24
|
+
absolute: true
|
|
25
|
+
});
|
|
26
|
+
for (const file of files)watchFiles.add(file);
|
|
27
|
+
}
|
|
28
|
+
return chokidar.watch(Array.from(watchFiles), options);
|
|
29
|
+
}
|
|
30
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
31
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
32
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
33
|
+
let cleaners = [];
|
|
34
|
+
const onBeforeRestart = (cleaner)=>{
|
|
35
|
+
cleaners.push(cleaner);
|
|
36
|
+
};
|
|
37
|
+
const clearConsole = ()=>{
|
|
38
|
+
if (isTTY() && !process.env.DEBUG) process.stdout.write('\x1B[H\x1B[2J');
|
|
39
|
+
};
|
|
40
|
+
const beforeRestart = async ({ filePath, root, clear = true })=>{
|
|
41
|
+
if (clear) clearConsole();
|
|
42
|
+
if (filePath) {
|
|
43
|
+
const filename = external_node_path_["default"].relative(root, filePath);
|
|
44
|
+
src_logger.info(`restarting Rstest as ${picocolors_default().yellow(filename)} changed\n`);
|
|
45
|
+
} else src_logger.info('restarting Rstest...\n');
|
|
46
|
+
for (const cleaner of cleaners)await cleaner();
|
|
47
|
+
cleaners = [];
|
|
48
|
+
};
|
|
49
|
+
const restart = async ({ filePath, clear = true, options, filters, root })=>{
|
|
50
|
+
await beforeRestart({
|
|
51
|
+
filePath,
|
|
52
|
+
root,
|
|
53
|
+
clear
|
|
54
|
+
});
|
|
55
|
+
await runRest({
|
|
56
|
+
options,
|
|
57
|
+
filters,
|
|
58
|
+
command: 'watch'
|
|
59
|
+
});
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
62
|
+
async function watchFilesForRestart({ rstest, watchOptions, options, filters }) {
|
|
63
|
+
const configFilePaths = [
|
|
64
|
+
rstest.context.configFilePath,
|
|
65
|
+
...rstest.context.projects.map((project)=>project.configFilePath)
|
|
66
|
+
].filter(Boolean);
|
|
67
|
+
if (0 === configFilePaths.length) return;
|
|
68
|
+
const root = rstest.context.rootPath;
|
|
69
|
+
const watcher = await createChokidar(configFilePaths, root, {
|
|
70
|
+
ignoreInitial: true,
|
|
71
|
+
ignorePermissionErrors: true,
|
|
72
|
+
...watchOptions
|
|
73
|
+
});
|
|
74
|
+
let restarting = false;
|
|
75
|
+
const onChange = async (filePath)=>{
|
|
76
|
+
if (restarting) return;
|
|
77
|
+
restarting = true;
|
|
78
|
+
const restarted = await restart({
|
|
79
|
+
options,
|
|
80
|
+
root,
|
|
81
|
+
filters,
|
|
82
|
+
filePath
|
|
83
|
+
});
|
|
84
|
+
if (restarted) await watcher.close();
|
|
85
|
+
else src_logger.error('Restart failed');
|
|
86
|
+
restarting = false;
|
|
87
|
+
};
|
|
88
|
+
watcher.on('add', onChange);
|
|
89
|
+
watcher.on('change', onChange);
|
|
90
|
+
watcher.on('unlink', onChange);
|
|
91
|
+
}
|
|
92
|
+
export { onBeforeRestart, watchFilesForRestart };
|