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