1
1
import path from "path" ;
2
2
import merge from "lodash/merge" ;
3
- import Module from "module" ;
4
3
import findUp from "find-up" ;
5
4
import Conf from "conf" ;
6
5
import TruffleError from "@truffle/error" ;
7
6
import originalRequire from "original-require" ;
8
7
import { getInitialConfig , configProps } from "./configDefaults" ;
9
8
import { EventManager } from "@truffle/events" ;
9
+ import debugModule from "debug" ;
10
+ const debug = debugModule ( "config" ) ;
10
11
11
12
const DEFAULT_CONFIG_FILENAME = "truffle-config.js" ;
12
13
const BACKUP_CONFIG_FILENAME = "truffle.js" ; // old config filename
@@ -117,6 +118,7 @@ class TruffleConfig {
117
118
if ( typeof clone [ key ] === "object" && this . _deepCopy . includes ( key ) ) {
118
119
this [ key ] = merge ( this [ key ] , clone [ key ] ) ;
119
120
} else {
121
+ debug ( "setting key -- %o -- to -- %o" , key , clone [ key ] ) ;
120
122
this [ key ] = clone [ key ] ;
121
123
}
122
124
} catch ( e ) {
@@ -162,6 +164,7 @@ class TruffleConfig {
162
164
}
163
165
164
166
public static detect ( options : any = { } , filename ?: string ) : TruffleConfig {
167
+ debug ( "callling Config.detect with filename -- %o" , filename ) ;
165
168
let configFile ;
166
169
const configPath = options . config ;
167
170
@@ -181,17 +184,15 @@ class TruffleConfig {
181
184
}
182
185
183
186
public static load ( file : string , options : any = { } ) : TruffleConfig {
187
+ debug ( "calling Config.load with file -- %o" , file ) ;
184
188
const workingDirectory = options . config
185
189
? process . cwd ( )
186
190
: path . dirname ( path . resolve ( file ) ) ;
187
191
188
192
const config = new TruffleConfig ( undefined , workingDirectory , undefined ) ;
189
193
190
- // The require-nocache module used to do this for us, but
191
- // it doesn't bundle very well. So we've pulled it out ourselves.
192
- //@ts -ignore
193
- delete require . cache [ Module . _resolveFilename ( file , module ) ] ;
194
194
const staticConfig = originalRequire ( file ) ;
195
+ debug ( "the static config is -- %o" , staticConfig ) ;
195
196
196
197
config . merge ( staticConfig ) ;
197
198
config . merge ( options ) ;
0 commit comments