Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 6572daa

Browse files
Add a helper function for better readability
1 parent f688f6d commit 6572daa

File tree

3 files changed

+11
-117
lines changed

3 files changed

+11
-117
lines changed

packages/core/lib/console-child.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const TruffleError = require("@truffle/error");
22
const Config = require("@truffle/config");
33
const yargs = require("yargs");
4+
const { deriveConfigEnvironment } = require("./command-utils");
45

56
// we split off the part Truffle cares about and need to convert to an array
67
const input = process.argv[2].split(" -- ");
@@ -13,24 +14,22 @@ global.crypto = {
1314
getRandomValues: require("get-random-values")
1415
};
1516

16-
//detect config so we can get the provider and resolver without having to serialize
17-
//and deserialize them
18-
const { network, config, url } = yargs(input[0]).argv;
19-
const detectedConfig = Config.detect({ network, config });
17+
function inheritConfig() {
18+
//detect config so we can get the provider and resolver without having to serialize
19+
//and deserialize them
20+
const { network, config, url } = yargs(input[0]).argv;
21+
const detectedConfig = Config.detect({ network, config });
22+
return deriveConfigEnvironment(detectedConfig, network, url);
23+
}
2024

2125
function main() {
22-
const {
23-
getCommand,
24-
prepareOptions,
25-
runCommand,
26-
deriveConfigEnvironment
27-
} = require("./command-utils");
28-
const derivedConfig = deriveConfigEnvironment(detectedConfig, network, url);
26+
const { getCommand, prepareOptions, runCommand } = require("./command-utils");
27+
const config = inheritConfig();
2928
const command = getCommand({ inputStrings, options: {}, noAliases: false });
3029
const options = prepareOptions({
3130
command,
3231
inputStrings,
33-
options: derivedConfig
32+
options: config
3433
});
3534

3635
runCommand(command, options)

packages/core/test/lib/console-child.js

Lines changed: 0 additions & 86 deletions
This file was deleted.

packages/core/test/sources/console-child/truffle-config.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)