dispose() { this._watcher.close(); Promise.resolve().then(() => process.exit(0)); }
build.getSource((err, source) => { if (err) { throw err } locales.on('change', (filePath) => { const locale = getLocale(filePath) if (!selectedLocales || selectedLocales.includes(locale)) { console.log(`The language ${locale} is changed, '${filePath}' is modified.`) dynamicallyBuildOnLanguages(source, locale) } }) locales.on('add', (filePath) => { const locale = getLocale(filePath) if (!selectedLocales || selectedLocales.includes(locale)) { console.log(`The language ${locale} is changed, '${filePath}' is added.`) dynamicallyBuildOnLanguages(source, locale) locales.add(filePath) } }) })
startWatcher(embedderPath, exludePattern, client, mainFileName) { this._embedderPath = fileURLToPath(embedderPath); this._client = client; this._watcher = chokidar.watch([this._embedderPath], { ignored: new RegExp(exludePattern), awaitWriteFinish: true, ignorePermissionErrors: true }); const events = []; this._watcher.on('all', (event, name) => { if (event === 'add' || event === 'change' || event === 'unlink') { if (!events.length) setTimeout(() => client.filesChanged(events.splice(0)), 100); events.push({ type: event, name: pathToFileURL(name).toString() }); } }); this._watcher.on('error', console.error); }
css.on('change', () => build.buildCSS())
.watch(slash(path.join(this.sourcePath, "/**/*")), { ignoreInitial: true, ignored: "**/node_modules/**" }) .on("ready", () => { debug("[WATCHING]".yellow, this.sourcePath); this.isWatching = true; this.emit("ready"); }) .on("add", this._onAdd.bind(this)) .on("addDir", this._onAdd.bind(this)) .on("change", this._onAdd.bind(this)) .on("unlink", this._onRemove.bind(this)) .on("unlinkDir", this._onRemove.bind(this)) .on("error", e => debug("[ERROR]".red, e)); } else { this.emit("ready");
layouts.on('change', () => build.fullBuild({ selectedLocales, preserveLocale }))
function createWatcher (...folders) { const watcher = chokidar.watch(folders, { ignored: /(^|[/\\])\../, persistent: true }) return watcher }
.watch(slash(path.join(this.sourcePath, "/**/*")), { ignoreInitial: true, ignored: "**/node_modules/**" }) .on("ready", () => { debug("[WATCHING]".yellow, this.sourcePath); this.isWatching = true; this.emit("ready"); }) .on("add", this._onAdd.bind(this)) .on("addDir", this._onAdd.bind(this)) .on("change", this._onAdd.bind(this)) .on("unlink", this._onRemove.bind(this)) .on("unlinkDir", this._onRemove.bind(this)) .on("error", e => debug("[ERROR]".red, e)); } else { this.emit("ready");