laravel-mix-glob
Version:
Laravel mix extension that add support for globs usage with an extensive concise api. For a more natural boosted productivity and dynamic. Configure once and forget about adding the files each time.
3 lines (2 loc) • 1.66 kB
JavaScript
"use strict";var t=require("chokidar"),s=require("../../Utils/Logger/index.js"),e=require("../RestartHandler/index.js");exports.WatchingHandler=class{shouldWatch;watchType;watchers=[];watchedFiles=[];watchedGlobs=[];_restartHandler;init(){return s.LOGGER.debug("Init should watch"),this._initShouldWatch(),s.LOGGER.debug("shouldWatch: "+(this.shouldWatch?"true":"false")),this.shouldWatch?(s.LOGGER.debug("init RestartHandler."),this._restartHandler=new e.RestartHandler,this._restartHandler.setWatchingHandler(this),{restartHandler:this._restartHandler}):{restartHandler:void 0}}_initShouldWatch(){return this.shouldWatch=process.argv.some((t=>t.includes("watch"))),this.shouldWatch&&(this.watchType="watch"),this.shouldWatch||(this.shouldWatch=process.argv.some((t=>t.includes("hot"))),this.shouldWatch&&(this.watchType="hot")),this.shouldWatch}watchForGlobs(e){return e.forEach((e=>{if(!this.watchedGlobs.includes(e)){let i;this.watchedGlobs.push(e),i=e.isGlobValueAnObject()?t.watch(e.value.pattern,{persistent:!0,usePolling:!0,ignoreInitial:!0,followSymlinks:!1!==e.value.options?.followSymbolicLinks,ignored:e.value.options?.ignore}):t.watch(e.value,{persistent:!0,usePolling:!0,ignoreInitial:!0,followSymlinks:!0}),this.watchers.push(i.on("add",(t=>{this._restartHandler.restartMix("add",t,e)})).on("unlink",(t=>{this._restartHandler.restartMix("unlink",t,e)})).on("unlinkDir",(t=>{s.LOGGER.debug("UNLINK DIR CHOKIDAR -------------"),s.LOGGER.debug(t),this._restartHandler.restartMix("unlinkDir",t,e)})))}})),this}addWatchedFiles(t){return t.forEach((t=>{this.watchedFiles.includes(t)||this.watchedFiles.push(t)})),this}};
//# sourceMappingURL=index.js.map