add reset cmd

This commit is contained in:
Iuri Matias 2018-01-11 09:22:58 -05:00
parent 3c8b10d597
commit 61c00819ec
4 changed files with 32 additions and 0 deletions

View File

@ -17,6 +17,7 @@ class Cmd {
this.blockchain();
this.simulator();
this.test();
this.reset();
this.upload();
this.versionCmd();
this.otherCommands();
@ -168,6 +169,19 @@ class Cmd {
});
}
reset() {
program
.command('reset')
.description('resets embarks state on this dapp including clearing cache')
.action(function (file) {
embark.initConfig('development', {
embarkConfig: 'embark.json', interceptLogs: false
});
embark.reset();
});
}
versionCmd() {
program
.command('version')

8
lib/cmds/reset.js Normal file
View File

@ -0,0 +1,8 @@
var fs = require('../core/fs.js');
module.exports = function() {
fs.removeSync('./chains.json');
fs.removeSync('.embark/');
fs.removeSync('dist/');
console.log("reset done!".green);
};

View File

@ -37,6 +37,10 @@ function existsSync() {
return fs.existsSync.apply(fs.existsSync, arguments);
}
function removeSync() {
return fs.removeSync.apply(fs.removeSync, arguments);
}
// returns embarks root directory
function embarkPath(fileOrDir) {
return utils.joinPath(__dirname, '/../../', fileOrDir);
@ -54,6 +58,7 @@ module.exports = {
readJSONSync: readJSONSync,
writeJSONSync: writeJSONSync,
existsSync: existsSync,
removeSync: removeSync,
embarkPath: embarkPath,
dappPath: dappPath
};

View File

@ -189,6 +189,11 @@ class Embark {
return new Test(options);
}
reset() {
let resetCmd = require('./cmds/reset.js');
resetCmd();
}
// TODO: should deploy if it hasn't already
upload(platform) {
let options = {