UNPKG

@nomiclabs/buidler

Version:

Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.

40 lines 1.85 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const debug_1 = __importDefault(require("debug")); const fs_extra_1 = __importDefault(require("fs-extra")); const config_env_1 = require("../internal/core/config/config-env"); const errors_1 = require("../internal/core/errors"); const errors_list_1 = require("../internal/core/errors-list"); const scripts_runner_1 = require("../internal/util/scripts-runner"); const task_names_1 = require("./task-names"); function default_1() { const log = debug_1.default("buidler:core:tasks:run"); config_env_1.task(task_names_1.TASK_RUN, "Runs a user-defined script after compiling the project") .addPositionalParam("script", "A js file to be run within buidler's environment") .addFlag("noCompile", "Don't compile before running this task") .setAction(async ({ script, noCompile }, { run, buidlerArguments }) => { if (!(await fs_extra_1.default.pathExists(script))) { throw new errors_1.BuidlerError(errors_list_1.ERRORS.BUILTIN_TASKS.RUN_FILE_NOT_FOUND, { script, }); } if (!noCompile) { await run(task_names_1.TASK_COMPILE); } log(`Running script ${script} in a subprocess so we can wait for it to complete`); try { process.exitCode = await scripts_runner_1.runScriptWithBuidler(buidlerArguments, script); } catch (error) { throw new errors_1.BuidlerError(errors_list_1.ERRORS.BUILTIN_TASKS.RUN_SCRIPT_ERROR, { script, error: error.message, }, error); } }); } exports.default = default_1; //# sourceMappingURL=run.js.map