@testomatio/reporter
Version:
Testomatio Reporter Client
54 lines (53 loc) • 1.9 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_child_process_1 = require("node:child_process");
const node_path_1 = require("node:path");
const utils_js_1 = require("../utils/utils.js");
const picocolors_1 = __importDefault(require("picocolors"));
// Define __dirname - this will be replaced by build script with actual __dirname for CommonJS
const cliPath = (0, node_path_1.join)(__dirname, 'cli.js');
const version = (0, utils_js_1.getPackageVersion)();
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
// Parse command line arguments to map start-test-run options to @testomatio/reporter run format
const args = process.argv.slice(2);
const newArgs = ['run'];
let i = 0;
while (i < args.length) {
const arg = args[i];
if (arg === '-c' || arg === '--command') {
// Map -c/--command to positional argument for run command
i++;
if (i < args.length) {
newArgs.push(args[i]);
}
}
else if (arg.startsWith('--command=')) {
// Handle --command=value format
const command = arg.split('=', 2)[1];
newArgs.push(command);
}
else if (arg === '--launch') {
// Map --launch to start command
newArgs[0] = 'start';
}
else if (arg === '--finish') {
// Map --finish to finish command
newArgs[0] = 'finish';
}
else {
// Pass through other arguments
newArgs.push(arg);
}
i++;
}
// Execute the main CLI with mapped arguments
const child = (0, node_child_process_1.spawn)(process.execPath, [cliPath, ...newArgs], {
stdio: 'inherit',
});
child.on('exit', code => {
process.exit(code);
});