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

Function executeCommandCallback

scripts/dev-watch.mjs:124–162  ·  view source on GitHub ↗
(filepath = '')

Source from the content-addressed store, hash-verified

122 }
123
124 function executeCommandCallback(filepath = '') {
125 return new Promise(async (resolve) => {
126 if (!processing) {
127 processing = true;
128 changedFiles.delete(filepath);
129
130 if (filepath.endsWith('.js') || filepath.endsWith('.ts')) {
131 // 1. ESM requires is always a full build because it ends up being bundled into a single "index.js" file
132 await executeCjsEsmBuilds();
133
134 // 2. for iife format, we can rebuild each separate file (unless it's the initial build, if so execute a full rebuild)
135 await (initialBuild
136 ? buildAllIifeFiles()
137 : buildIifeFile(filepath)
138 );
139 } else if (filepath.endsWith('.css') || filepath.endsWith('.scss')) {
140 // CSS/SCSS files
141 if (filepath.endsWith('.scss')) {
142 await buildSassFile(filepath);
143 }
144 }
145 // ELSE, reaching outside of the conditions above (i.e.: .html)
146 // will simply perform the common action, of reloading all connected browsers
147
148 // in every case, we want to reload the web page
149 bsync.reload('*.html');
150 processing = false;
151 if (initialBuild) {
152 initialBuild = false;
153 }
154
155 // we might still have other packages that have changes though, so re-execute the command callback process if any were found
156 if (hasQueuedChanges()) {
157 executeCommandCallback(Array.from(changedFiles).pop());
158 }
159 }
160 resolve(true);
161 });
162 }
163
164 async function destroy() {
165 console.log('Exiting the dev file watch...');

Callers 1

onFileChangedFunction · 0.85

Calls 5

executeCjsEsmBuildsFunction · 0.90
buildAllIifeFilesFunction · 0.90
buildIifeFileFunction · 0.90
buildSassFileFunction · 0.90
hasQueuedChangesFunction · 0.85

Tested by

no test coverage detected