tscoverage/dist/npmts.watch.js

31 lines
962 B
JavaScript
Raw Normal View History

2016-09-22 21:23:16 +00:00
"use strict";
const plugins = require("./npmts.plugins");
const promisechain = require("./npmts.promisechain");
2016-10-02 18:35:13 +00:00
const q = require("q");
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-09-22 21:23:16 +00:00
npmtsSmartchok = new plugins.smartchok.Smartchok(pathsToWatch);
npmtsSmartchok.getObservableFor('change').then((changeObservableArg) => {
plugins.beautylog.info('now watching...');
changeObservableArg.subscribe(() => {
promisechain.run(configArg);
});
});
npmtsSmartchok.start();
done.resolve(configArg);
}
else {
done.resolve(configArg);
}
return done.promise;
};