@@ -61,7 +61,8 @@ class Embark {
6161 env : options . env ,
6262 version : this . version ,
6363 embarkConfig : options . embarkConfig || 'embark.json' ,
64- logfile : options . logfile
64+ logFile : options . logFile ,
65+ logLevel : options . logLevel
6566 } ) ;
6667 engine . init ( ) ;
6768
@@ -150,16 +151,20 @@ class Embark {
150151 } ) ;
151152 }
152153
153- build ( options , engine , continueProcessing ) {
154- if ( ! engine ) {
155- engine = new Engine ( {
156- env : options . env ,
157- version : this . version ,
158- embarkConfig : 'embark.json' ,
159- interceptLogs : false
160- } ) ;
161- engine . init ( ) ;
162- }
154+ build ( options , continueProcessing ) {
155+ let engine = new Engine ( {
156+ env : options . env ,
157+ version : this . version ,
158+ embarkConfig : 'embark.json' ,
159+ interceptLogs : false ,
160+ logFile : options . logFile ,
161+ logLevel : options . logLevel ,
162+ events : options . events ,
163+ logger : options . logger ,
164+ config : options . config ,
165+ plugins : options . plugins
166+ } ) ;
167+ engine . init ( ) ;
163168
164169 async . waterfall ( [
165170 function startServices ( callback ) {
@@ -207,7 +212,7 @@ class Embark {
207212 env : options . env ,
208213 version : this . version ,
209214 embarkConfig : options . embarkConfig || 'embark.json' ,
210- logfile : options . logfile
215+ logFile : options . logFile
211216 } ) ;
212217 engine . init ( ) ;
213218
@@ -254,61 +259,57 @@ class Embark {
254259
255260 upload ( platform , options ) {
256261
262+ // populate options that were instantiated with initConfig to pass around
257263 options . buildDir = 'dist/' ;
258264 options . storageConfig = this . config . storageConfig ;
259-
260- // initialise embark engine
261- let engine = new Engine ( {
262- env : options . env ,
263- version : this . version ,
264- embarkConfig : options . embarkConfig || 'embark.json' ,
265- logfile : options . logfile
266- } ) ;
267- engine . init ( ) ;
265+ options . events = this . events ;
266+ options . logger = this . logger ;
267+ options . config = this . config ;
268268
269269 // load plugins
270270 this . plugins . loadInternalPlugin ( 'ipfs' , options ) ;
271271 this . plugins . loadInternalPlugin ( 'swarm' , options ) ;
272272
273- let plugins = this . plugins ;
273+ // upddate our options with loaded plugins
274+ options . plugins = this . plugins ;
275+
274276 let cmdPlugin ;
275277 let self = this ;
276278 async . waterfall ( [
277279 function setupStoragePlugin ( callback ) {
278280 // check use has input existing storage plugin
279- let cmdPlugins = plugins . getPluginsFor ( 'uploadCmds' ) ;
281+ let cmdPlugins = self . plugins . getPluginsFor ( 'uploadCmds' ) ;
280282
281283 if ( cmdPlugins . length > 0 ) {
282284 cmdPlugin = cmdPlugins . find ( ( pluginCmd ) => {
283285 return pluginCmd . name == platform ;
284286 } ) ;
285287 }
286288 if ( ! cmdPlugin ) {
287- engine . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
289+ self . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
288290 callback ( { message : 'unknown platform: ' + platform } ) ;
289291 } else {
290292 callback ( ) ;
291293 }
292294 } ,
293295 function buildAndDeployContracts ( callback ) {
294296 // 2. upload to storage (outputDone event triggered after webpack finished)
295- engine . events . on ( 'outputDone' , function ( ) {
296- engine . logger . info ( 'deploying to ' + platform + '...' ) ;
297+ self . events . on ( 'outputDone' , function ( ) {
297298 cmdPlugin . uploadCmds [ 0 ] . cb ( )
298299 . then ( ( success ) => {
299300 callback ( null , success ) ;
300301 } )
301302 . catch ( callback ) ;
302303 } ) ;
303304 // 1. build the contracts and dapp webpack
304- self . build ( options , engine , true ) ;
305+ self . build ( options , true ) ;
305306 }
306307 ] , function ( err , _result ) {
307308 if ( err ) {
308- engine . logger . error ( err . message ) ;
309- engine . logger . debug ( err . stack ) ;
309+ self . logger . error ( err . message ) ;
310+ self . logger . debug ( err . stack ) ;
310311 } else {
311- engine . logger . info ( "finished building dapp and deploying to " + platform . underline ) ;
312+ self . logger . info ( "finished building dapp and deploying to " + platform . underline ) ;
312313 }
313314
314315 // needed due to child processes
0 commit comments