UNPKG

fuse-box-typechecker-temp

Version:

Fuse-Box type checker plugin for fusebox 4.0.0 ++

45 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.watchSrc = void 0; const watch = require("watch"); const getPath_1 = require("./getPath"); const debugPrint_1 = require("./debugPrint"); const logger_1 = require("./logger"); let watchTimeout; function watchSrc(pathToWatch, options, callback) { debugPrint_1.debugPrint('wwatchSrc' + pathToWatch); let basePath = getPath_1.getPath(pathToWatch, options); watch.createMonitor(basePath, (monitor) => { // todo-> move into thread // tell user what path we are watching logger_1.Logger.echo(`<yellow> Typechecker watching: <yellow>${basePath}</yellow>`); // on created file event monitor.on('created', (f /*, stat: any*/) => { logger_1.Logger.echo(`<yellow>\n File created: ${f}</yellow>`); callback(); }); // on changed file event monitor.on('changed', (f /*, curr: any, prev: any*/) => { // tell user about event logger_1.Logger.echo(`<yellow>\n File changed: <grey>${f}</grey></yellow>`); logger_1.Logger.echo(`<grey> Calling typechecker</grey>`); // have inside timeout, so we only run once when multiple files are saved clearTimeout(watchTimeout); watchTimeout = setTimeout(() => { callback(); }, 100); }); monitor.on('removed', (f /*, stat: any*/) => { // tell user about event logger_1.Logger.echo(`<yellow>\n File removed: <grey>${f}</grey></yellow>`); logger_1.Logger.echo(`<grey> Calling typechecker</grey>`); // have inside timeout, so we only run once when multiple files are saved clearTimeout(watchTimeout); watchTimeout = setTimeout(() => { callback(); }, 100); }); }); } exports.watchSrc = watchSrc; //# sourceMappingURL=watchSrc.js.map