UNPKG

@tsed/cli-core

Version:
39 lines (38 loc) 1.14 kB
import { __decorate } from "tslib"; import { Injectable } from "@tsed/di"; import { execa, execaSync } from "execa"; import { filter, mergeWith } from "rxjs/operators"; // @ts-ignore import split from "split"; import { streamToObservable } from "../utils/streamToObservable.js"; let CliExeca = class CliExeca { constructor() { this.raw = execa; this.rawSync = execaSync; } /** * * @param cmd * @param args * @param opts */ run(cmd, args, opts) { const cp = this.raw(cmd, args, opts); const stdout = streamToObservable(cp.stdout.pipe(split()), { await: cp }); const stderr = streamToObservable(cp.stderr.pipe(split()), { await: cp }); return stdout.pipe(mergeWith(stderr)).pipe(filter(Boolean)); } runSync(cmd, args, opts) { return this.rawSync(cmd, args, opts); } async getAsync(cmd, args, opts) { return (await this.raw(cmd, args, opts)).stdout; } get(cmd, args, opts) { return this.rawSync(cmd, args, opts).stdout; } }; CliExeca = __decorate([ Injectable() ], CliExeca); export { CliExeca };