UNPKG

harmonyc

Version:

Harmony Code - model-driven BDD for Vitest

36 lines (35 loc) 1.03 kB
import Watcher from 'watcher'; import { compileFile, compileFiles } from "../compiler/compiler.js"; export async function watchFiles(patterns) { const { fns, outFns } = await compileFiles(patterns); for (const file of fns) { const watcher = new Watcher(file, { debounce: 20, ignoreInitial: true }); watcher.on('all', async () => { var _a; try { await compileFile(file); } catch (e) { process.stdout.write(`\n`); console.log((_a = e.message) !== null && _a !== void 0 ? _a : e); process.stdout.write(`\n`); } logger.log(`Compiled ${file}`); }); } return outFns; } const logger = { last: '', n: 0, log(msg) { if (msg === this.last) { process.stdout.write(`\r${msg} ${++this.n}x`); } else { process.stdout.write(`\r${msg}`); this.last = msg; this.n = 1; } }, };