1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | var __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 | };
|
12 | Object.defineProperty(exports, "__esModule", { value: true });
|
13 | const debug_1 = __importDefault(require("debug"));
|
14 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
15 | const path = __importStar(require("path"));
|
16 | const semver = __importStar(require("semver"));
|
17 | const config_env_1 = require("../internal/core/config/config-env");
|
18 | const scripts_runner_1 = require("../internal/util/scripts-runner");
|
19 | const task_names_1 = require("./task-names");
|
20 | function 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 |
|
36 | await scripts_runner_1.runScriptWithBuidler(buidlerArguments, "", [], nodeArgs, {
|
37 | NODE_REPL_HISTORY: historyFile,
|
38 | });
|
39 | });
|
40 | }
|
41 | exports.default = default_1;
|
42 |
|
\ | No newline at end of file |