MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / startPluginWatcher

Function startPluginWatcher

utils/scripts/dev.js:390–417  ·  view source on GitHub ↗
(platform)

Source from the content-addressed store, hash-verified

388let pluginPlatform = "android";
389
390function startPluginWatcher(platform) {
391 pluginPlatform = platform;
392 let chokidar;
393 try {
394 chokidar = require("chokidar");
395 } catch (_e) {
396 log("warn", "chokidar not installed — plugin auto-update disabled");
397 return;
398 }
399
400 if (!fs.existsSync(PLUGINS)) {
401 log("warn", "src/plugins/ not found — plugin watcher skipped");
402 return;
403 }
404
405 const watcher = chokidar.watch(path.join(PLUGINS, "**", "*"), {
406 ignored: /(^|[\/\\])\../, // dotfiles
407 persistent: true,
408 ignoreInitial: true,
409 awaitWriteFinish: { stabilityThreshold: 500, pollInterval: 100 },
410 });
411
412 watcher.on("change", (filePath) => schedulePluginUpdate(filePath));
413 watcher.on("add", (filePath) => schedulePluginUpdate(filePath));
414 watcher.on("unlink", (filePath) => schedulePluginUpdate(filePath));
415
416 log("info", "Watching src/plugins/ for changes...");
417}
418
419function schedulePluginUpdate(filePath) {
420 // Extract top-level plugin dir name from path

Callers 1

mainFunction · 0.85

Calls 3

schedulePluginUpdateFunction · 0.85
logFunction · 0.70
onMethod · 0.45

Tested by

no test coverage detected