1
1
const TruffleError = require ( "@truffle/error" ) ;
2
2
const Config = require ( "@truffle/config" ) ;
3
3
const yargs = require ( "yargs" ) ;
4
+ const { deriveConfigEnvironment } = require ( "./command-utils" ) ;
4
5
5
6
// we split off the part Truffle cares about and need to convert to an array
6
7
const input = process . argv [ 2 ] . split ( " -- " ) ;
@@ -13,24 +14,22 @@ global.crypto = {
13
14
getRandomValues : require ( "get-random-values" )
14
15
} ;
15
16
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
+ }
20
24
21
25
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 ( ) ;
29
28
const command = getCommand ( { inputStrings, options : { } , noAliases : false } ) ;
30
29
const options = prepareOptions ( {
31
30
command,
32
31
inputStrings,
33
- options : derivedConfig
32
+ options : config
34
33
} ) ;
35
34
36
35
runCommand ( command , options )
0 commit comments