@excute/cli
Version:
Execute JSX on anywhere
44 lines (43 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const core_1 = require("@oclif/core");
const libs_1 = require("../../libs");
class RunCommand extends core_1.Command {
async run() {
const { args } = await this.parse(RunCommand);
// get filename from argv
const filename = path.join(process.cwd(), args.filename);
// this.log(`📑 ${filename}`);
// 1. transpile
const transpiledResult = (0, libs_1.compile)([filename]);
// 2. run
(0, libs_1.run)(transpiledResult);
}
async catch(error) {
var _a;
if ((_a = core_1.CliUx.ux.action.task) === null || _a === void 0 ? void 0 : _a.active) {
core_1.CliUx.ux.action.stop(`
[❌ ERROR] ${error}
${error.stack}`);
}
throw error;
}
}
exports.default = RunCommand;
RunCommand.description = "Run your code with JSX";
RunCommand.examples = [
`$ excute run ./examples/jsx-server/src/app.tsx`,
`$ excute run --help`,
`$ npx excute run --help`,
];
RunCommand.flags = {
// from: Flags.string({
// char: "f",
// description: "Whom is saying hello",
// required: true,
// }),
};
RunCommand.args = [
{ name: "filename", description: "Read from stdin", required: true },
];