MCPcopy Create free account
hub / github.com/6pac/SlickGrid / init

Function init

scripts/dev-watch.mjs:37–69  ·  view source on GitHub ↗

* initialize @parcel/watcher watch & init browserSync * We are watching the files with extensions (.js, .ts, .html, .css, .scss) but we'll ignore folders like node_modules, dist & .git * Note: the watcher often send duplicate events, however the use of Set of file changes & the use of a setTim

()

Source from the content-addressed store, hash-verified

35 * Note: the watcher often send duplicate events, however the use of Set of file changes & the use of a setTimeout delay gets rid of this problem.
36 */
37 async function init() {
38 subscription = subscribe(process.cwd(), (err, events) => {
39 if (err) return onError(err);
40
41 for (const event of events) {
42 const absoluteFilePath = relative(process.cwd(), event.path);
43 onFileChanged(absoluteFilePath);
44 }
45 }, {
46 ignore: [
47 '**/.git/**',
48 '**/dist/**',
49 '**/cypress/**',
50 '**/node_modules/**',
51 '!**/*.{ts,js,html,css,scss}' // which file extensions to watch
52 ]
53 });
54
55 // also watch for any Signal termination to cleanly exit the watch command
56 process.once('SIGINT', () => destroy());
57 process.once('SIGTERM', () => destroy());
58 process.stdin.on('end', () => destroy());
59 process.stdin.on('exit', () => process.stdin.destroy());
60
61 // run full prod build `/dist` and full SASS build
62 if (!argv.serve) {
63 await executeFullBuild();
64 buildAllSassFiles(); // start SASS build but no need to await it
65 }
66
67 // start browser-sync server
68 startBrowserSync();
69 }
70
71 /**
72 * Initialize and start BrowserSync

Callers 1

dev-watch.mjsFile · 0.70

Calls 7

executeFullBuildFunction · 0.90
buildAllSassFilesFunction · 0.90
onErrorFunction · 0.85
onFileChangedFunction · 0.85
startBrowserSyncFunction · 0.85
destroyFunction · 0.70
destroyMethod · 0.45

Tested by

no test coverage detected