tscoverage/dist/npmts.watch.js

34 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2016-09-22 21:23:16 +00:00
"use strict";
2017-02-27 21:19:14 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2017-01-17 23:58:09 +00:00
const q = require("smartq");
2016-10-21 15:48:52 +00:00
const smartchok = require("smartchok");
const plugins = require("./npmts.plugins");
const cli = require("./npmts.cli");
2016-09-22 21:23:16 +00:00
let npmtsSmartchok = null;
exports.run = (configArg) => {
2016-10-02 18:35:13 +00:00
let done = q.defer();
2016-09-22 21:23:16 +00:00
if (configArg.watch && npmtsSmartchok === null) {
let pathsToWatch = [];
for (let key in configArg.ts) {
pathsToWatch.push(key);
}
2016-09-25 18:22:10 +00:00
for (let key in configArg.testTs) {
pathsToWatch.push(key);
}
2016-10-21 15:48:52 +00:00
npmtsSmartchok = new smartchok.Smartchok(pathsToWatch);
npmtsSmartchok.getObservableFor('change').then(changeObservableArg => {
2016-09-22 21:23:16 +00:00
plugins.beautylog.info('now watching...');
changeObservableArg.subscribe(() => {
2016-10-21 15:48:52 +00:00
cli.run();
2016-09-22 21:23:16 +00:00
});
});
npmtsSmartchok.start();
done.resolve(configArg);
}
else {
2016-10-21 15:48:52 +00:00
plugins.beautylog.info('not watching');
2016-09-22 21:23:16 +00:00
done.resolve(configArg);
}
return done.promise;
};