11let async = require ( 'async' ) ;
2+ const constants = require ( './constants' ) ;
23// require("./utils/debug_util.js")(__filename, async);
34
45require ( 'colors' ) ;
@@ -31,29 +32,33 @@ class Embark {
3132 this . events = new Events ( ) ;
3233 this . logger = new Logger ( { logLevel : 'debug' , events : this . events } ) ;
3334
34- this . config = new Config ( { env : env , logger : this . logger , events : this . events } ) ;
35+ this . config = new Config ( { env : env , logger : this . logger , events : this . events , context : this . context } ) ;
3536 this . config . loadConfigFiles ( options ) ;
3637 this . plugins = this . config . plugins ;
3738 }
3839
3940 blockchain ( env , client ) {
41+ this . context = [ constants . contexts . blockchain ] ;
4042 return require ( './cmds/blockchain/blockchain.js' ) ( this . config . blockchainConfig , client , env ) . run ( ) ;
4143 }
4244
4345 simulator ( options ) {
46+ this . context = options . context || [ constants . contexts . simulator , constants . contexts . blockchain ] ;
4447 let Simulator = require ( './cmds/simulator.js' ) ;
4548 let simulator = new Simulator ( { blockchainConfig : this . config . blockchainConfig } ) ;
4649 simulator . run ( options ) ;
4750 }
4851
4952 generateTemplate ( templateName , destinationFolder , name ) {
53+ this . context = [ constants . contexts . templateGeneration ] ;
5054 let TemplateGenerator = require ( './cmds/template_generator.js' ) ;
5155 let templateGenerator = new TemplateGenerator ( templateName ) ;
5256 templateGenerator . generate ( destinationFolder , name ) ;
5357 }
5458
5559 run ( options ) {
5660 let self = this ;
61+ self . context = options . context || [ constants . contexts . run , constants . contexts . build ] ;
5762 let Dashboard = require ( './dashboard/dashboard.js' ) ;
5863 let windowSize = require ( 'window-size' ) ;
5964
@@ -62,7 +67,8 @@ class Embark {
6267 version : this . version ,
6368 embarkConfig : options . embarkConfig || 'embark.json' ,
6469 logFile : options . logFile ,
65- logLevel : options . logLevel
70+ logLevel : options . logLevel ,
71+ context : self . context
6672 } ) ;
6773 engine . init ( ) ;
6874
@@ -152,6 +158,7 @@ class Embark {
152158 }
153159
154160 build ( options , continueProcessing ) {
161+ this . context = options . context || [ constants . contexts . build ] ;
155162 let engine = new Engine ( {
156163 env : options . env ,
157164 version : this . version ,
@@ -162,7 +169,8 @@ class Embark {
162169 events : options . events ,
163170 logger : options . logger ,
164171 config : options . config ,
165- plugins : options . plugins
172+ plugins : options . plugins ,
173+ context : this . context
166174 } ) ;
167175 engine . init ( ) ;
168176
@@ -201,18 +209,22 @@ class Embark {
201209 }
202210
203211 initTests ( options ) {
212+ this . context = options . context || [ constants . contexts . test ] ;
204213 let Test = require ( './tests/test.js' ) ;
214+ options . context = this . context ;
205215 return new Test ( options ) ;
206216 }
207217
208218 graph ( options ) {
219+ this . context = options . context || [ constants . contexts . graph ] ;
209220 options . onlyCompile = true ;
210221
211222 let engine = new Engine ( {
212223 env : options . env ,
213224 version : this . version ,
214225 embarkConfig : options . embarkConfig || 'embark.json' ,
215- logFile : options . logFile
226+ logFile : options . logFile ,
227+ context : this . context
216228 } ) ;
217229 engine . init ( ) ;
218230
@@ -253,11 +265,13 @@ class Embark {
253265 }
254266
255267 reset ( ) {
268+ this . context = [ constants . contexts . reset ] ;
256269 let resetCmd = require ( './cmds/reset.js' ) ;
257270 resetCmd ( ) ;
258271 }
259272
260273 upload ( platform , options ) {
274+ this . context = options . context || [ constants . contexts . upload , constants . contexts . build ] ;
261275
262276 // populate options that were instantiated with initConfig to pass around
263277 options . buildDir = 'dist/' ;
@@ -318,6 +332,7 @@ class Embark {
318332 }
319333
320334 runTests ( file ) {
335+ this . context = [ constants . contexts . test ] ;
321336 let RunTests = require ( './tests/run_tests.js' ) ;
322337 RunTests . run ( file ) ;
323338 }
@@ -327,6 +342,7 @@ class Embark {
327342// temporary until next refactor
328343Embark . initTests = function ( options ) {
329344 let Test = require ( './tests/test.js' ) ;
345+ options . context = [ constants . contexts . test ] ;
330346 return new Test ( options ) ;
331347} ;
332348
0 commit comments