mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 14:34:40 +00:00
refactor exec cmd
This commit is contained in:
parent
d5c7bf3133
commit
431b37173e
30
bin/embark
30
bin/embark
@ -6,6 +6,12 @@ var wrench = require('wrench');
|
|||||||
var grunt = require('grunt');
|
var grunt = require('grunt');
|
||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
|
|
||||||
|
var run = function(cmd) {
|
||||||
|
if (exec(cmd).code != 0) {
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('0.2.1')
|
.version('0.2.1')
|
||||||
|
|
||||||
@ -19,39 +25,39 @@ program.command('new [name]').description('New application').action(function(nam
|
|||||||
var targetDir = "./" + name;
|
var targetDir = "./" + name;
|
||||||
wrench.copyDirSyncRecursive(prefPath, targetDir);
|
wrench.copyDirSyncRecursive(prefPath, targetDir);
|
||||||
cd(targetDir);
|
cd(targetDir);
|
||||||
exec('npm install');
|
run('npm install');
|
||||||
console.log('\n\ninit complete');
|
console.log('\n\ninit complete');
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('deploy [env]').description('deploy contracts').action(function(env_) {
|
program.command('deploy [env]').description('deploy contracts').action(function(env_) {
|
||||||
var env = env_ || 'development';
|
var env = env_ || 'development';
|
||||||
exec("grunt deploy_contracts:" + env);
|
run("grunt deploy_contracts:" + env);
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('build [env]').description('build dapp').action(function(env_) {
|
program.command('build [env]').description('build dapp').action(function(env_) {
|
||||||
var env = env_ || 'development';
|
var env = env_ || 'development';
|
||||||
exec("grunt clean");
|
run("grunt clean");
|
||||||
exec("grunt deploy_contracts:" + env);
|
run("grunt deploy_contracts:" + env);
|
||||||
exec('grunt build:' + env);
|
run('grunt build:' + env);
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('ipfs [env]').description('build dapp and make it available in ipfs').action(function(env_) {
|
program.command('ipfs [env]').description('build dapp and make it available in ipfs').action(function(env_) {
|
||||||
var env = env_ || 'development';
|
var env = env_ || 'development';
|
||||||
if (exec("grunt clean").code != 0) { exit(); }
|
run("grunt clean")
|
||||||
if (exec("grunt deploy_contracts:" + env).code != 0) { exit(); }
|
run("grunt deploy_contracts:" + env)
|
||||||
if (exec('grunt build:' + env).code != 0) { exit(); }
|
run('grunt build:' + env)
|
||||||
if (exec('grunt ipfs:' + env).code != 0) { exit(); }
|
run('grunt ipfs:' + env)
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('run [env]').description('run dapp').action(function(env_) {
|
program.command('run [env]').description('run dapp').action(function(env_) {
|
||||||
var env = env_ || 'development';
|
var env = env_ || 'development';
|
||||||
exec('grunt deploy:' + env);
|
run('grunt deploy:' + env);
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('blockchain [env]').description('run blockchain').action(function(env_) {
|
program.command('blockchain [env]').description('run blockchain').action(function(env_) {
|
||||||
var env = env_ || 'development';
|
var env = env_ || 'development';
|
||||||
|
|
||||||
exec('grunt blockchain:' + env);
|
run('grunt blockchain:' + env);
|
||||||
});
|
});
|
||||||
|
|
||||||
program.command('demo').description('create a working dapp with a SimpleStorage contract').action(function() {
|
program.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
|
|||||||
wrench.copyDirSyncRecursive(demoPath, targetDir + "/app", {forceDelete: true});
|
wrench.copyDirSyncRecursive(demoPath, targetDir + "/app", {forceDelete: true});
|
||||||
|
|
||||||
cd(targetDir);
|
cd(targetDir);
|
||||||
exec('npm install');
|
run('npm install');
|
||||||
console.log('\n\ninit complete');
|
console.log('\n\ninit complete');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user