neex
Version:
Neex - Modern Fullstack Framework Built on Express and Next.js. Fast to Start, Easy to Build, Ready to Deploy
72 lines (71 loc) • 3.2 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = run;
exports.runParallel = runParallel;
exports.runSequential = runSequential;
exports.runServers = runServers;
// src/index.ts - Updated version
const runner_1 = require("./runner");
const logger_1 = __importDefault(require("./logger"));
/**
* Run one or more commands in parallel or sequentially
*/
async function run(commands, options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
const cmdArray = Array.isArray(commands) ? commands : [commands];
const runOptions = {
parallel: (_a = options === null || options === void 0 ? void 0 : options.parallel) !== null && _a !== void 0 ? _a : false,
maxParallel: options === null || options === void 0 ? void 0 : options.maxParallel,
printOutput: (_b = options === null || options === void 0 ? void 0 : options.printOutput) !== null && _b !== void 0 ? _b : true,
color: (_c = options === null || options === void 0 ? void 0 : options.color) !== null && _c !== void 0 ? _c : true,
showTiming: (_d = options === null || options === void 0 ? void 0 : options.showTiming) !== null && _d !== void 0 ? _d : true,
prefix: (_e = options === null || options === void 0 ? void 0 : options.prefix) !== null && _e !== void 0 ? _e : true,
stopOnError: (_f = options === null || options === void 0 ? void 0 : options.stopOnError) !== null && _f !== void 0 ? _f : false,
minimalOutput: (_g = options === null || options === void 0 ? void 0 : options.minimalOutput) !== null && _g !== void 0 ? _g : false,
groupOutput: (_h = options === null || options === void 0 ? void 0 : options.groupOutput) !== null && _h !== void 0 ? _h : false,
isServerMode: (_j = options === null || options === void 0 ? void 0 : options.isServerMode) !== null && _j !== void 0 ? _j : false,
retry: options === null || options === void 0 ? void 0 : options.retry,
retryDelay: options === null || options === void 0 ? void 0 : options.retryDelay
};
const runner = new runner_1.Runner(runOptions);
if (options === null || options === void 0 ? void 0 : options.registerCleanup) {
options.registerCleanup(() => runner.cleanup());
}
const results = await runner.run(cmdArray);
if (runOptions.printOutput && cmdArray.length > 1) {
logger_1.default.printSummary(results);
}
return results;
}
/**
* Run multiple commands in parallel
*/
async function runParallel(commands, options) {
return run(commands, { ...options, parallel: true });
}
/**
* Run multiple commands sequentially
*/
async function runSequential(commands, options) {
return run(commands, { ...options, parallel: false });
}
/**
* Run multiple servers with optimized output
*/
async function runServers(commands, options) {
return run(commands, {
...options,
parallel: true,
isServerMode: true,
printOutput: true
});
}
exports.default = {
run,
runParallel,
runSequential,
runServers
};