@uuv/runner-commons
Version:
A common lib for uuv
55 lines (54 loc) • 2.1 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UUVCliEngine = void 0;
const helper_1 = require("./helper");
const chalk_1 = __importDefault(require("chalk"));
const options_1 = require("./options");
class UUVCliEngine {
runner;
constructor(runner) {
this.runner = runner;
}
async execute() {
let ipcServerProcess;
try {
helper_1.UUVCliHelper.printBanner(this.runner.name, this.runner.getCurrentVersion());
this.checkArguments();
const options = helper_1.UUVCliHelper.extractArgs(this.runner.projectDir, this.runner.defaultBrowser);
helper_1.UUVCliHelper.printVariables(options);
if (options.command === undefined) {
throw new Error("Unknown command");
}
ipcServerProcess = helper_1.UUVCliHelper.startIpcServer();
await this.runner.prepare(options);
console.info(chalk_1.default.blueBright(`Executing UUV command ${options.command}...`));
switch (options.command) {
case options_1.UUV_TARGET_COMMAND.OPEN:
await this.runner.executeOpenCommand(options);
break;
case options_1.UUV_TARGET_COMMAND.RUN:
case options_1.UUV_TARGET_COMMAND.E2E:
await this.runner.executeE2eCommand(options);
break;
}
console.info(`UUV command ${options.command} executed`);
}
catch (e) {
console.error(chalk_1.default.red(e));
process.exit(1);
}
finally {
if (ipcServerProcess) {
helper_1.UUVCliHelper.stopIpcServer(ipcServerProcess);
}
}
}
checkArguments() {
helper_1.UUVCliHelper.checkTargetCommand();
helper_1.UUVCliHelper.checkTargetTestFiles();
}
}
exports.UUVCliEngine = UUVCliEngine;