@joystick.js/cli-canary 0.0.0-canary.602 → 0.0.0-canary.603
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import d from"chokidar";import f from"fs";import{dirname as h}from"path";import m from"../../build/build_files.js";import y from"../../debounce.js";import _ from"./get_after_run_tasks.js";import g from"./get_file_codependencies.js";import o from"../../build/get_file_operation.js";import k from"../../build/get_path_platform.js";import v from"../../types.js";import w from"./watch_paths.js";const{mkdir:l,copyFile:R,rm:p}=f.promises,n=async(e={},i={})=>{const r=process.initial_build_complete?await g(e?.path):[];if(i?.is_build_file&&await m({files:[{path:e?.path,platform:k(e?.path)}]}).catch((t=[])=>{if(!process.initial_build_complete&&t?.length>0&&process.exit(0),process.initial_build_complete&&t?.length>0)throw process.app_server_process.send(JSON.stringify({type:"BUILD_ERROR",paths:t.filter(({success:a})=>!a)})),process.hmr_server_process.send(JSON.stringify({type:"BUILD_ERROR"})),new Error("BUILD_ERROR")}),r?.length>0)for(let t=0;t<r?.length;t+=1){const a=r[t];return n({path:a},i)}return Promise.resolve()},b=async(e={})=>{switch(e?.operation){case"add_directory":return l(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return n(e,{is_build_file:!0});case"copy_file":return await l(h(`.joystick/build/${e?.path}`),{recursive:!0}),await R(e?.path,`.joystick/build/${e?.path}`),n(e,{is_build_file:!1});case"delete_directory":return p(`.joystick/build/${e?.path}`,{recursive:!0});case"delete_file":return await p(`.joystick/build/${e?.path}`,{recursive:!0}),n(e,{is_build_file:!1});default:return!0}},D=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:o(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),B=(e={})=>({operation:o(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>{switch(e?.event){case"add_file":return B(e);case"change_file":return E(e);case"delete_file":return $(e);case"add_directory":return O(e);case"delete_directory":return D(e)}},L=async(e=[],i={})=>{try{const r=new Set([]);for(let t=0;t<e?.length;t+=1){const a=e[t],s=I(a);if(await b(s),s?.after_run_tasks)for(let c=0;c<s?.after_run_tasks?.length;c+=1){const u=s?.after_run_tasks[c];r.add(u)}}setTimeout(async()=>{const t=Array.from(r);for(let a=0;a<t?.length;a+=1){const s=t[a];v.is_function(i[s])&&await i[s](e)}},300)}catch{}},S=(e="")=>{switch(e){case"add":return"add_file";case"change":return"change_file";case"unlink":return"delete_file";case"addDir":return"add_directory";case"unlinkDir":return"delete_directory"}},U=(e={})=>{const i=d.watch(w.map(({path:t})=>t),{ignored:".joystick"});let r=[];process.initial_build_complete=!1,i.on("error",t=>console.error(t)),i.on("all",(t,a)=>{r.push({event:S(t),path:a}),y(async()=>{await L(r,e),process.initial_build_complete=!0,r=[]},100)})};var H=U;export{H as default};
|
package/package.json
CHANGED
|
@@ -149,15 +149,17 @@ const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) =>
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
setTimeout(async () => {
|
|
153
|
+
const tasks_to_run = Array.from(after_run_tasks);
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
for (let i = 0; i < tasks_to_run?.length; i += 1) {
|
|
156
|
+
const after_run_task = tasks_to_run[i];
|
|
156
157
|
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
if (types.is_function(after_run_functions[after_run_task])) {
|
|
159
|
+
await after_run_functions[after_run_task](jobs);
|
|
160
|
+
}
|
|
159
161
|
}
|
|
160
|
-
}
|
|
162
|
+
}, 300);
|
|
161
163
|
} catch(error) {
|
|
162
164
|
// NOTE: Dead catch as we just want to avoid after_run_tasks from running. Actual
|
|
163
165
|
// errors are handled as part of run_job() (e.g., build errors are handled as a part
|