Skip to content

Instantly share code, notes, and snippets.

Last active January 12, 2019 11:53
What would you like to do?
import {MarkdownService, RendererService, FileSystemService, PuppeteerService, IngestService} from './services/_index';
import {IWorkflowConfig} from './entities/_index';
import {CommanderService} from './services/commander-service';
import {empty, Observable, Observer, Subject} from "rxjs";
import {IAppState} from "./entities/IAppStream";
import {Command} from "commander";
import {flatMap, mergeMap} from "rxjs/operators";
const appState: IAppState = {};
const cs = new CommanderService();
const app$: Observable<IAppState> = Observable.create((obs: Observer<IAppState>) => {
const appRun = app$.pipe(
(source) => cs.convertAction(),
(sourceValue, commandValue) => {
// console.log(sourceValue, commandValue);
sourceValue.command = commandValue.args[0];
return sourceValue;
.subscribe((data) => {
console.log('End result: ', data);
// Produces: End result: { command: './files' }
// I want to substitute this for the second param in mergeMap() but not sure how...
const mergeCommanderToAppState = (appState: IAppState, commanderValues: Command) => {
appState.command = commanderValues.usage();
return appState;
import {IWorkflowConfig} from "./iWorkflowConfig";
import {IMarkdown} from "./iMarkdown";
import {Browser} from "puppeteer";
import {Command} from "commander";
export interface IAppState {
workflowConfig?: IWorkflowConfig;
template?: string;
styles?: string;
markdownFiles?: IMarkdown[];
browser?: Browser;
command?: string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment