@@ -6,6 +6,12 @@ var wrench = require('wrench');
66var grunt = require ( 'grunt' ) ;
77require ( 'shelljs/global' ) ;
88
9+ var run = function ( cmd ) {
10+ if ( exec ( cmd ) . code != 0 ) {
11+ exit ( ) ;
12+ }
13+ }
14+
915program
1016 . version ( '0.2.1' )
1117
@@ -19,39 +25,39 @@ program.command('new [name]').description('New application').action(function(nam
1925 var targetDir = "./" + name ;
2026 wrench . copyDirSyncRecursive ( prefPath , targetDir ) ;
2127 cd ( targetDir ) ;
22- exec ( 'npm install' ) ;
28+ run ( 'npm install' ) ;
2329 console . log ( '\n\ninit complete' ) ;
2430} ) ;
2531
2632program . command ( 'deploy [env]' ) . description ( 'deploy contracts' ) . action ( function ( env_ ) {
2733 var env = env_ || 'development' ;
28- exec ( "grunt deploy_contracts:" + env ) ;
34+ run ( "grunt deploy_contracts:" + env ) ;
2935} ) ;
3036
3137program . command ( 'build [env]' ) . description ( 'build dapp' ) . action ( function ( env_ ) {
3238 var env = env_ || 'development' ;
33- exec ( "grunt clean" ) ;
34- exec ( "grunt deploy_contracts:" + env ) ;
35- exec ( 'grunt build:' + env ) ;
39+ run ( "grunt clean" ) ;
40+ run ( "grunt deploy_contracts:" + env ) ;
41+ run ( 'grunt build:' + env ) ;
3642} ) ;
3743
3844program . command ( 'ipfs [env]' ) . description ( 'build dapp and make it available in ipfs' ) . action ( function ( env_ ) {
3945 var env = env_ || 'development' ;
40- if ( exec ( "grunt clean" ) . code != 0 ) { exit ( ) ; }
41- if ( exec ( "grunt deploy_contracts:" + env ) . code != 0 ) { exit ( ) ; }
42- if ( exec ( 'grunt build:' + env ) . code != 0 ) { exit ( ) ; }
43- if ( exec ( 'grunt ipfs:' + env ) . code != 0 ) { exit ( ) ; }
46+ run ( "grunt clean" )
47+ run ( "grunt deploy_contracts:" + env )
48+ run ( 'grunt build:' + env )
49+ run ( 'grunt ipfs:' + env )
4450} ) ;
4551
4652program . command ( 'run [env]' ) . description ( 'run dapp' ) . action ( function ( env_ ) {
4753 var env = env_ || 'development' ;
48- exec ( 'grunt deploy:' + env ) ;
54+ run ( 'grunt deploy:' + env ) ;
4955} ) ;
5056
5157program . command ( 'blockchain [env]' ) . description ( 'run blockchain' ) . action ( function ( env_ ) {
5258 var env = env_ || 'development' ;
5359
54- exec ( 'grunt blockchain:' + env ) ;
60+ run ( 'grunt blockchain:' + env ) ;
5561} ) ;
5662
5763program . command ( 'demo' ) . description ( 'create a working dapp with a SimpleStorage contract' ) . action ( function ( ) {
@@ -63,7 +69,7 @@ program.command('demo').description('create a working dapp with a SimpleStorage
6369 wrench . copyDirSyncRecursive ( demoPath , targetDir + "/app" , { forceDelete : true } ) ;
6470
6571 cd ( targetDir ) ;
66- exec ( 'npm install' ) ;
72+ run ( 'npm install' ) ;
6773 console . log ( '\n\ninit complete' ) ;
6874} ) ;
6975
0 commit comments