UNPKG

1.97 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5var __importStar = (this && this.__importStar) || function (mod) {
6 if (mod && mod.__esModule) return mod;
7 var result = {};
8 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9 result["default"] = mod;
10 return result;
11};
12Object.defineProperty(exports, "__esModule", { value: true });
13const debug_1 = __importDefault(require("debug"));
14const fs_extra_1 = __importDefault(require("fs-extra"));
15const path = __importStar(require("path"));
16const semver = __importStar(require("semver"));
17const config_env_1 = require("../internal/core/config/config-env");
18const scripts_runner_1 = require("../internal/util/scripts-runner");
19const task_names_1 = require("./task-names");
20function default_1() {
21 const log = debug_1.default("buidler:core:tasks:console");
22 config_env_1.task(task_names_1.TASK_CONSOLE, "Opens a buidler console")
23 .addFlag("noCompile", "Don't compile before running this task")
24 .setAction(async ({ noCompile }, { config, run, buidlerArguments }) => {
25 if (!noCompile) {
26 await run("compile");
27 }
28 await fs_extra_1.default.ensureDir(config.paths.cache);
29 const historyFile = path.join(config.paths.cache, "console-history.txt");
30 const nodeArgs = [];
31 if (semver.gte(process.version, "10.0.0")) {
32 nodeArgs.push("--experimental-repl-await");
33 }
34 log(`Creating a Node REPL subprocess with Buidler's register so we can set some Node's flags`);
35 // Running the script "" is like running `node`, so this starts the repl
36 await scripts_runner_1.runScriptWithBuidler(buidlerArguments, "", [], nodeArgs, {
37 NODE_REPL_HISTORY: historyFile,
38 });
39 });
40}
41exports.default = default_1;
42//# sourceMappingURL=console.js.map
\No newline at end of file