fix(core): update

This commit is contained in:
Philipp Kunz 2019-10-14 14:53:55 +02:00
parent 21b962b9a8
commit e20508ffbc
3 changed files with 15 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import { Watcher } from './tswatch.classes.watcher';
export class TsWatch {
public watchmode: interfaces.TWatchModes;
public watcherMap = new plugins.lik.Objectmap<Watcher>();
public smartserve: plugins.smartserve.SmartServe;
constructor(watchmodeArg: interfaces.TWatchModes) {
this.watchmode = watchmodeArg;
@ -37,12 +38,11 @@ export class TsWatch {
break;
case 'gitzone_element':
// lets create a standard server
const smartserve = new plugins.smartserve.SmartServe({
this.smartserve = new plugins.smartserve.SmartServe({
port: 3001,
injectReload: true,
serveDir: plugins.path.join(paths.cwd, './dist_web/')
});
await smartserve.start();
this.watcherMap.add(
new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
@ -88,12 +88,18 @@ export class TsWatch {
this.watcherMap.forEach(async watcher => {
await watcher.start();
});
if (this.smartserve) {
await this.smartserve.start();
}
}
/**
* stops the execution of any active Watchers
*/
public async stop() {
if (this.smartserve) {
await this.smartserve.stop();
}
this.watcherMap.forEach(async watcher => {
await watcher.stop();
});

View File

@ -55,7 +55,7 @@ export class Watcher {
changeObservable.subscribe(() => {
this.updateCurrentExecution();
});
this.updateCurrentExecution();
await this.updateCurrentExecution();
}
/**

View File

@ -26,4 +26,10 @@ tswatchCli.addCommand('element').subscribe(async argvArg => {
await tsWatch.start();
});
tswatchCli.addCommand('npm').subscribe(async argvArg => {
logger.log('info', `running watch task for a gitzone element project`);
const tsWatch = new TsWatch('gitzone_npm');
await tsWatch.start();
});
tswatchCli.startParse();