@@ -78,14 +78,14 @@ module.exports = {
78
78
}
79
79
80
80
if ( docker_opt ) {
81
- runDocker ( coverage_opt , datasource , version_opt )
81
+ runDocker ( coverage_opt , datasource , version_opt , print )
82
82
} else {
83
- runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt )
83
+ runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt , print )
84
84
}
85
85
}
86
86
}
87
87
88
- async function runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt ) {
88
+ async function runBinary ( coverage_opt , datasource , force_opt , logs_opt , version_opt , print ) {
89
89
const platform = getPlatform ( logs_opt )
90
90
91
91
if ( ! version_opt ) {
@@ -104,8 +104,8 @@ async function runBinary(coverage_opt, datasource, force_opt, logs_opt, version_
104
104
force_opt ? await binary . install ( true ) : await binary . install ( false )
105
105
let args = ""
106
106
107
- if ( datasource ) { args = datasource }
108
- if ( coverage_opt ) { args = args + ' -c' }
107
+ datasource ? args = datasource : args
108
+ coverage_opt ? args = args + ' -c' : args
109
109
args !== '' ? binary . run ( args . trim ( ) ) : binary . run ( )
110
110
}
111
111
@@ -144,9 +144,9 @@ function getPlatform(logs_opt) {
144
144
throw new Error ( `Unsupported platform: ${ type } ${ arch } ${ majorVersion } ` )
145
145
}
146
146
147
- function runDocker ( coverage_opt , datasource , version_opt ) {
148
- // Remove the binaries before because there are permission issues
149
- // with the binaries when building the docker images
147
+ function runDocker ( coverage_opt , datasource , version_opt , print ) {
148
+ // Remove binary-install-raw binaries, because docker has permission issues
149
+ // when building the docker images
150
150
fs . rmSync ( "node_modules/binary-install-raw/bin" , { force : true , recursive : true } ) ;
151
151
152
152
let dir = 'tests/.docker' ;
@@ -155,15 +155,14 @@ function runDocker(coverage_opt, datasource, version_opt) {
155
155
fs . mkdirSync ( dir , { recursive : true } ) ;
156
156
}
157
157
158
- fs . writeFileSync ( 'tests/.docker/Dockerfile' , dockerfile ( version_opt ) , ( err ) => {
159
- if ( err ) {
160
- print . info ( 'A problem occurred while generating the Dockerfile. Please attend to the errors below.' ) ;
161
- print . info ( err ) ;
162
- }
163
- else {
164
- print . info ( 'Successfully generated Dockerfile.' )
165
- }
166
- } )
158
+ try {
159
+ fs . writeFileSync ( `${ dir } /Dockerfile` , dockerfile ( version_opt ) )
160
+ print . info ( 'Successfully generated Dockerfile.' ) ;
161
+ } catch ( error ) {
162
+ print . info ( 'A problem occurred while generating the Dockerfile. Please attend to the errors below:' ) ;
163
+ print . info ( chalk . red ( error ) ) ;
164
+ return
165
+ }
167
166
168
167
// Run a command to check if matchstick image already exists
169
168
exec ( 'docker images -q matchstick' , ( error , stdout , stderr ) => {
0 commit comments