This repository was archived by the owner on Apr 22, 2021. It is now read-only.
File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' ) ;
1
2
const truffleConfig = require ( 'truffle-config' ) ;
2
3
const findUp = require ( 'find-up' ) ;
3
4
@@ -8,21 +9,34 @@ async function getTruffleConfig(opts) {
8
9
return file ;
9
10
}
10
11
12
+ async function getNetworksConfig ( opts ) {
13
+ const file = await findUp ( 'networks.js' , opts ) ;
14
+ return file ;
15
+ }
16
+
11
17
// Extracts artifacts directory from Tuffle and OpenZeppelin configs
12
18
async function getBuildDir ( { network, cwd } ) {
13
19
if ( ! network ) {
14
20
throw new Error ( 'You must specify the network name to deploy to.' ) ;
15
21
}
16
22
17
23
let config ;
24
+
25
+ // Look for networks.js
26
+ const networksConfig = await getNetworksConfig ( { cwd } ) ;
27
+ if ( networksConfig ) {
28
+ // At that moment networks.js always use /build/contracts as a build folder
29
+ // but that may change in the future
30
+ return path . resolve ( cwd , './build/contracts' ) ;
31
+ }
32
+
18
33
const truffleConfigPath = await getTruffleConfig ( { cwd } ) ;
19
34
if ( truffleConfigPath ) {
20
35
config = truffleConfig . load ( truffleConfigPath , { network } ) ;
21
- } else {
22
- throw new Error ( 'No Truffle Config file found!' ) ;
36
+ return config . contracts_build_directory ;
23
37
}
24
38
25
- return config . contracts_build_directory ;
39
+ throw new Error ( 'No Truffle or Networks.js Config file found!' ) ;
26
40
}
27
41
28
42
module . exports = {
You can’t perform that action at this time.
0 commit comments