@@ -61,9 +61,8 @@ class Embark {
6161 env : options . env ,
6262 version : this . version ,
6363 embarkConfig : options . embarkConfig || 'embark.json' ,
64- logfile : options . logfile ,
65- logLevel : options . logLevel ,
66- interceptLogs : true
64+ logFile : options . logFile ,
65+ logLevel : options . logLevel
6766 } ) ;
6867 engine . init ( ) ;
6968
@@ -149,16 +148,20 @@ class Embark {
149148 } ) ;
150149 }
151150
152- build ( options , engine , continueProcessing ) {
153- if ( ! engine ) {
154- engine = new Engine ( {
155- env : options . env ,
156- version : this . version ,
157- embarkConfig : 'embark.json' ,
158- interceptLogs : false
159- } ) ;
160- engine . init ( ) ;
161- }
151+ build ( options , continueProcessing ) {
152+ let engine = new Engine ( {
153+ env : options . env ,
154+ version : this . version ,
155+ embarkConfig : 'embark.json' ,
156+ interceptLogs : false ,
157+ logFile : options . logFile ,
158+ logLevel : options . logLevel ,
159+ events : options . events ,
160+ logger : options . logger ,
161+ config : options . config ,
162+ plugins : options . plugins
163+ } ) ;
164+ engine . init ( ) ;
162165
163166 async . waterfall ( [
164167 function startServices ( callback ) {
@@ -206,7 +209,7 @@ class Embark {
206209 env : options . env ,
207210 version : this . version ,
208211 embarkConfig : options . embarkConfig || 'embark.json' ,
209- logfile : options . logfile
212+ logFile : options . logFile
210213 } ) ;
211214 engine . init ( ) ;
212215
@@ -254,61 +257,57 @@ class Embark {
254257 // TODO: should deploy if it hasn't already
255258 upload ( platform , options ) {
256259
260+ // populate options that were instantiated with initConfig to pass around
257261 options . buildDir = 'dist/' ;
258262 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 ( ) ;
263+ options . events = this . events ;
264+ options . logger = this . logger ;
265+ options . config = this . config ;
268266
269267 // load plugins
270268 this . plugins . loadInternalPlugin ( 'ipfs' , options ) ;
271269 this . plugins . loadInternalPlugin ( 'swarm' , options ) ;
272270
273- let plugins = this . plugins ;
271+ // upddate our options with loaded plugins
272+ options . plugins = this . plugins ;
273+
274274 let cmdPlugin ;
275275 let self = this ;
276276 async . waterfall ( [
277277 function setupStoragePlugin ( callback ) {
278278 // check use has input existing storage plugin
279- let cmdPlugins = plugins . getPluginsFor ( 'uploadCmds' ) ;
279+ let cmdPlugins = self . plugins . getPluginsFor ( 'uploadCmds' ) ;
280280
281281 if ( cmdPlugins . length > 0 ) {
282282 cmdPlugin = cmdPlugins . find ( ( pluginCmd ) => {
283283 return pluginCmd . name == platform ;
284284 } ) ;
285285 }
286286 if ( ! cmdPlugin ) {
287- engine . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
287+ self . logger . info ( 'try "embark upload ipfs" or "embark upload swarm"' . green ) ;
288288 callback ( { message : 'unknown platform: ' + platform } ) ;
289289 } else {
290290 callback ( ) ;
291291 }
292292 } ,
293293 function buildAndDeployContracts ( callback ) {
294294 // 2. upload to storage (outputDone event triggered after webpack finished)
295- engine . events . on ( 'outputDone' , function ( ) {
296- engine . logger . info ( 'deploying to ' + platform + '...' ) ;
295+ self . events . on ( 'outputDone' , function ( ) {
297296 cmdPlugin . uploadCmds [ 0 ] . cb ( )
298297 . then ( ( success ) => {
299298 callback ( null , success ) ;
300299 } )
301300 . catch ( callback ) ;
302301 } ) ;
303302 // 1. build the contracts and dapp webpack
304- self . build ( options , engine , true ) ;
303+ self . build ( options , true ) ;
305304 }
306305 ] , function ( err , _result ) {
307306 if ( err ) {
308- engine . logger . error ( err . message ) ;
309- engine . logger . debug ( err . stack ) ;
307+ self . logger . error ( err . message ) ;
308+ self . logger . debug ( err . stack ) ;
310309 } else {
311- engine . logger . info ( "finished building dapp and deploying to " + platform . underline ) ;
310+ self . logger . info ( "finished building dapp and deploying to " + platform . underline ) ;
312311 }
313312
314313 // needed due to child processes
0 commit comments