@tsed/cli-core
Version:
Build your CLI with TypeScript and Decorators
26 lines (25 loc) • 717 B
JavaScript
import { inject } from "@tsed/di";
import { Observable } from "rxjs";
import { CliExeca } from "../../services/CliExeca.js";
export class BaseManager {
constructor() {
this.verboseOpt = "--verbose";
this.cliExeca = inject(CliExeca);
}
has() {
try {
this.cliExeca.runSync(this.cmd, ["--version"]);
return true;
}
catch (er) {
return false;
}
}
async init(opts) { }
runScript(script, options) {
return this.run("run", [script], options);
}
run(cmd, args, options) {
return this.cliExeca.run(this.cmd, [cmd, options.verbose && this.verboseOpt, ...args].filter(Boolean), options);
}
}