UNPKG

kist

Version:

Lightweight Package Pipeline Processor with Plugin Architecture

38 lines 1.47 kB
import { __awaiter } from "tslib"; import { execFile } from "child_process"; import path from "path"; import util from "util"; import { Action } from "../../core/pipeline/Action.js"; const execFileAsync = util.promisify(execFile); export class RunScriptAction extends Action { execute(options) { return __awaiter(this, void 0, void 0, function* () { const { scriptPath, args = [] } = options; if (!scriptPath) { throw new Error("Invalid options: 'scriptPath' is required."); } const resolvedScriptPath = path.resolve(scriptPath); this.logInfo(`Executing external script: ${resolvedScriptPath}...`); try { const { stdout, stderr } = yield execFileAsync("node", [ resolvedScriptPath, ...args, ]); if (stderr) { this.logError(`Script execution failed: ${stderr}`); throw new Error(stderr); } this.logInfo(stdout); this.logInfo("Script executed successfully."); } catch (error) { this.logError("Error occurred while executing the script.", error); throw error; } }); } describe() { return "Executes an external JavaScript file as part of the KIST pipeline."; } } //# sourceMappingURL=RunScriptAction.js.map