tscoverage/ts/npmts.watch.ts

35 lines
1.0 KiB
TypeScript
Raw Normal View History

2017-01-18 00:58:09 +01:00
import * as q from 'smartq'
2016-10-21 17:48:52 +02:00
import * as smartchok from 'smartchok'
import * as plugins from './npmts.plugins'
import * as cli from './npmts.cli'
2016-10-02 20:35:13 +02:00
2016-10-21 17:48:52 +02:00
import { INpmtsConfig } from './npmts.config'
2016-09-22 23:23:16 +02:00
2016-10-21 17:48:52 +02:00
let npmtsSmartchok: smartchok.Smartchok = null
2016-09-25 20:22:10 +02:00
export let run = (configArg: INpmtsConfig) => {
2016-10-02 20:35:13 +02:00
let done = q.defer()
2016-09-22 23:23:16 +02:00
if (configArg.watch && npmtsSmartchok === null) {
let pathsToWatch: string[] = []
for (let key in configArg.ts) {
pathsToWatch.push(key)
}
2016-09-25 20:22:10 +02:00
for (let key in configArg.testTs) {
pathsToWatch.push(key)
}
2016-10-21 17:48:52 +02:00
npmtsSmartchok = new smartchok.Smartchok(pathsToWatch)
2016-09-22 23:23:16 +02:00
npmtsSmartchok.getObservableFor('change').then((changeObservableArg) => {
plugins.beautylog.info('now watching...')
changeObservableArg.subscribe(() => {
2016-10-21 17:48:52 +02:00
cli.run()
2016-09-22 23:23:16 +02:00
})
})
npmtsSmartchok.start()
done.resolve(configArg)
} else {
2016-10-21 17:48:52 +02:00
plugins.beautylog.info('not watching')
2016-09-22 23:23:16 +02:00
done.resolve(configArg)
}
return done.promise
}