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.blockchain();
this.simulator(); this.simulator();
this.test(); this.test();
this.reset();
this.upload(); this.upload();
this.versionCmd(); this.versionCmd();
this.otherCommands(); 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() { versionCmd() {
program program
.command('version') .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); return fs.existsSync.apply(fs.existsSync, arguments);
} }
function removeSync() {
return fs.removeSync.apply(fs.removeSync, arguments);
}
// returns embarks root directory // returns embarks root directory
function embarkPath(fileOrDir) { function embarkPath(fileOrDir) {
return utils.joinPath(__dirname, '/../../', fileOrDir); return utils.joinPath(__dirname, '/../../', fileOrDir);
@ -54,6 +58,7 @@ module.exports = {
readJSONSync: readJSONSync, readJSONSync: readJSONSync,
writeJSONSync: writeJSONSync, writeJSONSync: writeJSONSync,
existsSync: existsSync, existsSync: existsSync,
removeSync: removeSync,
embarkPath: embarkPath, embarkPath: embarkPath,
dappPath: dappPath dappPath: dappPath
}; };

View File

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