@@ -3,15 +3,37 @@ const fse = require("fs-extra");
3
3
const externalCompile = require ( "@truffle/external-compile" ) ;
4
4
const solcCompile = require ( "@truffle/compile-solidity" ) ;
5
5
const vyperCompile = require ( "@truffle/compile-vyper" ) ;
6
- const { prepareConfig } = require ( "../utils" ) ;
7
6
const { Shims } = require ( "@truffle/compile-common" ) ;
7
+ const expect = require ( "@truffle/expect" ) ;
8
+ const Config = require ( "@truffle/config" ) ;
9
+ const Artifactor = require ( "@truffle/artifactor" ) ;
10
+ const Resolver = require ( "@truffle/resolver" ) ;
8
11
9
12
const SUPPORTED_COMPILERS = {
10
13
solc : solcCompile ,
11
14
vyper : vyperCompile ,
12
15
external : externalCompile
13
16
} ;
14
17
18
+ function prepareConfig ( options ) {
19
+ expect . options ( options , [ "contracts_build_directory" ] ) ;
20
+
21
+ expect . one ( options , [ "contracts_directory" , "files" ] ) ;
22
+
23
+ // Use a config object to ensure we get the default sources.
24
+ const config = Config . default ( ) . merge ( options ) ;
25
+
26
+ config . compilersInfo = { } ;
27
+
28
+ if ( ! config . resolver ) config . resolver = new Resolver ( config ) ;
29
+
30
+ if ( ! config . artifactor ) {
31
+ config . artifactor = new Artifactor ( config . contracts_build_directory ) ;
32
+ }
33
+
34
+ return config ;
35
+ }
36
+
15
37
const WorkflowCompile = {
16
38
collectCompilations : async compilations => {
17
39
let result = { outputs : { } , contracts : { } } ;
@@ -103,9 +125,8 @@ const WorkflowCompile = {
103
125
const { contracts, output } = compilations . reduce (
104
126
( a , compilation ) => {
105
127
for ( const contract of compilation . contracts ) {
106
- a . contracts [
107
- contract . contractName
108
- ] = Shims . NewToLegacy . forContract ( contract ) ;
128
+ a . contracts [ contract . contractName ] =
129
+ Shims . NewToLegacy . forContract ( contract ) ;
109
130
}
110
131
a . output = a . output . concat ( compilation . sourceIndexes ) ;
111
132
return a ;
0 commit comments