@@ -3,17 +3,18 @@ const util = require('util');
33const readdir = util . promisify ( fs . readdir ) ;
44const path = require ( "path" ) ;
55const artifactsPath = path . join ( __dirname , "../artifacts/" ) ;
6+ const buidlerConfigSol5 = path . join ( __dirname , "../buidlerConfigSol5.js" ) ;
7+ const buidlerConfigSol4 = path . join ( __dirname , "../buidlerConfigSol4.js" ) ;
68const execSync = require ( 'child_process' ) . execSync ;
79
810module . exports . retrieveArtifacts = main ;
9- async function main ( ) {
10- if ( fs . existsSync ( artifactsPath ) ) {
11- let output = await packageArtifacts ( ) ;
12- return output ;
13- } else {
14- compileArtifacts ( ) ;
15- main ( ) ;
11+ async function main ( skipCompilation ) {
12+ if ( ! skipCompilation ) {
13+ compileContracts ( ) ;
1614 }
15+ let output = await packageArtifacts ( ) ;
16+ console . log ( output )
17+ return output ;
1718}
1819
1920async function packageArtifacts ( ) {
@@ -27,11 +28,11 @@ async function packageArtifacts() {
2728}
2829
2930
30- function compileArtifacts ( ) {
31- console . log ( "Artifacts not found. Compiling contracts..." ) ;
32- execSync ( ' npx buidler compile' , { encoding : 'utf-8' } ) ;
33- execSync ( ' npx buidler compile --config ../ buidlerConfigSol5.js' , { encoding : 'utf-8' } ) ;
34- execSync ( ' npx buidler compile --config ../ buidlerConfigSol4.js' , { encoding : 'utf-8' } ) ;
31+ function compileContracts ( ) {
32+ console . log ( "Compiling contracts..." ) ;
33+ execSync ( ` npx buidler compile` , { encoding : 'utf-8' } ) ;
34+ execSync ( ` npx buidler compile --config ${ buidlerConfigSol5 } ` , { encoding : 'utf-8' } ) ;
35+ execSync ( ` npx buidler compile --config ${ buidlerConfigSol4 } ` , { encoding : 'utf-8' } ) ;
3536}
3637
3738main ( ) ;
0 commit comments