tscoverage/ts/npmts.watch.ts

30 lines
1015 B
TypeScript
Raw Permalink Normal View History

2016-09-22 21:23:16 +00:00
import * as plugins from './npmts.plugins'
import * as promisechain from './npmts.promisechain'
let npmtsSmartchok: plugins.smartchok.Smartchok = null
2016-09-25 18:22:10 +00:00
import { INpmtsConfig } from './npmts.options'
2016-09-22 21:23:16 +00:00
2016-09-25 18:22:10 +00:00
export let run = (configArg: INpmtsConfig) => {
2016-09-22 21:23:16 +00:00
let done = plugins.q.defer()
if (configArg.watch && npmtsSmartchok === null) {
let pathsToWatch: string[] = []
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
}