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.88 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; const debug_1 = __importDefault(require("debug")); const context_1 = require("../context"); const config_loading_1 = require("../core/config/config-loading"); const errors_1 = require("../core/errors"); const errors_list_1 = require("../core/errors-list"); const buidler_params_1 = require("../core/params/buidler-params"); const env_variables_1 = require("../core/params/env-variables"); const runtime_environment_1 = require("../core/runtime-environment"); let ctx; let env; if (context_1.BuidlerContext.isCreated()) { ctx = context_1.BuidlerContext.getBuidlerContext(); // The most probable reason for this to happen is that this file was imported // from the config file if (ctx.environment === undefined) { throw new errors_1.BuidlerError(errors_list_1.ERRORS.GENERAL.LIB_IMPORTED_FROM_THE_CONFIG); } env = ctx.environment; } else { ctx = context_1.BuidlerContext.createBuidlerContext(); const buidlerArguments = env_variables_1.getEnvBuidlerArguments(buidler_params_1.BUIDLER_PARAM_DEFINITIONS, process.env); if (buidlerArguments.verbose) { debug_1.default.enable("buidler*"); } const config = config_loading_1.loadConfigAndTasks(buidlerArguments); // TODO: This is here for backwards compatibility. // There are very few projects using this. if (buidlerArguments.network === undefined) { buidlerArguments.network = config.defaultNetwork; } env = new runtime_environment_1.Environment(config, buidlerArguments, ctx.tasksDSL.getTaskDefinitions(), ctx.extendersManager.getExtenders(), ctx.experimentalBuidlerEVMMessageTraceHooks); ctx.setBuidlerRuntimeEnvironment(env); } module.exports = env; //# sourceMappingURL=buidler-lib.js.map