diff --git a/lib/cmd.js b/lib/cmd.js index 2fb13ceb5..52cb113eb 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -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') diff --git a/lib/cmds/reset.js b/lib/cmds/reset.js new file mode 100644 index 000000000..c2b14756d --- /dev/null +++ b/lib/cmds/reset.js @@ -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); +}; diff --git a/lib/core/fs.js b/lib/core/fs.js index a98aa06d3..3db858841 100644 --- a/lib/core/fs.js +++ b/lib/core/fs.js @@ -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 }; diff --git a/lib/index.js b/lib/index.js index b2f0e00f1..a1a38193c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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 = {