From 5ca5403483d4ab55a39268af3cbbcd3cbcdb7cb6 Mon Sep 17 00:00:00 2001 From: Sean Pertet Date: Fri, 28 Jan 2022 20:31:58 +0000 Subject: [PATCH 1/2] Add watch for js api --- src/framework/connector.ts | 1 + src/framework/watch.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/framework/connector.ts b/src/framework/connector.ts index 57f421b..71dd980 100644 --- a/src/framework/connector.ts +++ b/src/framework/connector.ts @@ -2,6 +2,7 @@ import { FlatMapAsyncOptions, flatMapAsync, pipe, compose, map, tap, Transform, import * as t from 'io-ts' import { PathReporter } from 'io-ts/lib/PathReporter' import R from "ramda"; +import { watchScope } from './watch'; export function connector< Config, diff --git a/src/framework/watch.ts b/src/framework/watch.ts index 0649ec3..c3dd624 100644 --- a/src/framework/watch.ts +++ b/src/framework/watch.ts @@ -1,7 +1,7 @@ import { Command, ConnectorScope, OutputElement } from "./connector"; import { onEnd, tap, compose, pipe, streamJson, transformJson } from "@space48/json-pipe"; import ipc from "node-ipc"; -import { MessageHeader, Path } from "."; +import { MessageHeader, Path, State } from "."; import { encodeHeader } from './binary-api'; import { throws } from "assert"; import { time, timeStamp } from "console"; @@ -20,7 +20,7 @@ export function watchScope(scope: ConnectorScope): ConnectorScope { } catch (e) { progress.finish(e); throw e - } + } } }; } @@ -181,7 +181,10 @@ class ExecutionProgress { }; } - recordOutput(output: unknown) { + recordOutput(output: any) { + if(State.isState(output)) { + return; + } if (this.multiCommand) { const outputEl = output as OutputElement; this.getCommandProgress(outputEl).recordOutput(); From 3619002dbd297b604d9e438d393154da18f5edb5 Mon Sep 17 00:00:00 2001 From: Sean Pertet Date: Fri, 28 Jan 2022 20:35:05 +0000 Subject: [PATCH 2/2] Wrap scope with watch scope --- src/framework/connector.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/framework/connector.ts b/src/framework/connector.ts index 71dd980..5f45a79 100644 --- a/src/framework/connector.ts +++ b/src/framework/connector.ts @@ -24,7 +24,7 @@ export function connector< const executeCommands = commandExecutor(definition.resources, _scope); - return { + return watchScope({ scopeName: definition.getScopeName(config.get()), connector, @@ -80,7 +80,7 @@ export function connector< } } }, - } + }) } const connector = addPropertiesToFunction(