From e20508ffbcb30ed3be6980b54836572c5cb9a953 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 14 Oct 2019 14:53:55 +0200 Subject: [PATCH] fix(core): update --- ts/tswatch.classes.tswatch.ts | 10 ++++++++-- ts/tswatch.classes.watcher.ts | 2 +- ts/tswatch.cli.ts | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ts/tswatch.classes.tswatch.ts b/ts/tswatch.classes.tswatch.ts index 86710a2..49cea6b 100644 --- a/ts/tswatch.classes.tswatch.ts +++ b/ts/tswatch.classes.tswatch.ts @@ -7,6 +7,7 @@ import { Watcher } from './tswatch.classes.watcher'; export class TsWatch { public watchmode: interfaces.TWatchModes; public watcherMap = new plugins.lik.Objectmap(); + 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(); }); diff --git a/ts/tswatch.classes.watcher.ts b/ts/tswatch.classes.watcher.ts index fe0bd05..a64d8fa 100644 --- a/ts/tswatch.classes.watcher.ts +++ b/ts/tswatch.classes.watcher.ts @@ -55,7 +55,7 @@ export class Watcher { changeObservable.subscribe(() => { this.updateCurrentExecution(); }); - this.updateCurrentExecution(); + await this.updateCurrentExecution(); } /** diff --git a/ts/tswatch.cli.ts b/ts/tswatch.cli.ts index da47650..0007678 100644 --- a/ts/tswatch.cli.ts +++ b/ts/tswatch.cli.ts @@ -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();