UNPKG

@moonsong-labs/moonwall-cli

Version:

Testing framework for the Moon family of projects

85 lines (83 loc) 2.95 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/internal/runner.ts var runner_exports = {}; __export(runner_exports, { runTask: () => runTask, spawnTask: () => spawnTask }); module.exports = __toCommonJS(runner_exports); var import_child_process = __toESM(require("child_process"), 1); var import_node_util = require("util"); var import_debug = __toESM(require("debug"), 1); var debug = (0, import_debug.default)("actions:runner"); var execAsync = (0, import_node_util.promisify)(import_child_process.default.exec); async function runTask(cmd, { cwd, env } = { cwd: process.cwd() }, title) { debug(`${title ? `Title: ${title} ` : ""}Running task on directory ${cwd}: ${cmd} `); try { const result = await execAsync(cmd, { cwd, env }); return result.stdout; } catch (error) { console.log(error); debug(`Caught exception in command execution. Error[${error.status}] ${error.message} `); throw error; } } async function spawnTask(cmd, { cwd, env } = { cwd: process.cwd() }, title) { debug(`${title ? `Title: ${title} ` : ""}Running task on directory ${process.cwd()}: ${cmd} `); try { const process2 = import_child_process.default.spawn( cmd.split(" ")[0], cmd.split(" ").slice(1).filter((a) => a.length > 0), { cwd, env } ); return process2; } catch (error) { console.log(error); debug(`Caught exception in command execution. Error[${error.status}] ${error.message} `); throw error; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { runTask, spawnTask });