UNPKG

@tsed/cli

Version:
40 lines (39 loc) 1.26 kB
import { CliFs, command, inject, normalizePath, ProjectPackageJson } from "@tsed/cli-core"; import { taskLogger } from "@tsed/cli-tasks"; import { CliRunScript } from "../../services/CliRunScript.js"; export class RunCmd { constructor() { this.fs = inject(CliFs); this.projectPackageJson = inject(ProjectPackageJson); this.runScript = inject(CliRunScript); } async $exec(ctx) { const cmd = "node"; const args = ["--import", "@swc-node/register/esm-register"]; const path = normalizePath("src/bin/index.ts"); taskLogger().info(`Run ${cmd} ${[...args, path, ctx.command, ...ctx.rawArgs].join(" ")}`); await this.runScript.run(cmd, [...args, path, ctx.command, ...ctx.rawArgs], { env: process.env }); } } command({ token: RunCmd, name: "run", description: "Run a project level command", args: { command: { description: "The project command", type: String, required: true } }, options: { "-p, --production": { type: Boolean, defaultValue: false, description: "Set production profile to NODE_ENV" } }, allowUnknownOption: true });