UNPKG

pact-toolbox

Version:

A tool to help you build, test and deploy your Pact smart contracts

54 lines (52 loc) 1.45 kB
const require_chunk = require('./chunk-CUT6urMc.cjs'); const citty = require_chunk.__toESM(require("citty")); const __pact_toolbox_script = require_chunk.__toESM(require("@pact-toolbox/script")); const __pact_toolbox_utils = require_chunk.__toESM(require("@pact-toolbox/utils")); //#region src/commands/run.ts const runCommand = (0, citty.defineCommand)({ meta: { name: "run", description: "Run a script with the toolbox runtime" }, args: { script: { type: "positional", name: "script", description: "Script to run", required: true }, start: { type: "boolean", name: "start", alias: "s", description: "Start the network before running the script", required: false, default: true }, network: { type: "string", name: "network", alias: "n", description: "Network to use", required: false } }, run: async ({ args }) => { const { script, network, start,...rest } = args; __pact_toolbox_utils.logger.start(`Running script ${script} ${network ? `on network ${network}` : ""}`); try { await (0, __pact_toolbox_script.runScript)(script, { network, args: rest, scriptOptions: { autoStartNetwork: start } }); } catch (error) { __pact_toolbox_utils.logger.error(`Error running script ${script}:`, error); process.exit(1); } __pact_toolbox_utils.logger.success(`Script ${script} finished`); process.exit(0); } }); //#endregion exports.runCommand = runCommand;