@ts-bridge/cli
Version:
Bridge the gap between ES modules and CommonJS modules with an easy-to-use alternative to `tsc`.
26 lines (25 loc) • 831 B
JavaScript
import { error, info } from './logging.js';
/**
* Execute a list of steps in series. Each step receives the context object,
* and can conditionally execute based on the context.
*
* @param steps - The steps to execute.
* @param context - The context object that will be passed to each step.
* @param verbose - Whether to log each step as it is executed.
*/
export function executeSteps(steps, context, verbose) {
try {
for (const step of steps) {
// If the step has a condition, and it returns false, we skip the step.
if (step.condition && !step.condition(context)) {
continue;
}
verbose && info(step.name);
step.task(context);
}
}
catch (_error) {
error(_error, verbose);
process.exitCode = 1;
}
}