Skip to content
Snippets Groups Projects
Commit cab6cdbd authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] #941 Added `preventIfRunning` field for commands of modules

parent 8af356f0
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ module.exports = {
cli: [{
name: 'reapply-to [number]',
desc: 'Reapply reverted blocks until block #[number] is reached. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: (server, conf, program, params) => co(function*() {
const number = params[0];
const logger = server.logger;
......
......@@ -11,6 +11,7 @@ module.exports = {
cli: [{
name: 'reset [config|data|peers|tx|stats|all]',
desc: 'Reset configuration, data, peers, transactions or everything in the database',
preventIfRunning: true,
onConfiguredExecute: (server, conf, program, params, wizardTasks) => co(function*() {
const type = params[0];
......
......@@ -7,6 +7,8 @@ module.exports = {
cli: [{
name: 'revert [count]',
desc: 'Revert (undo + remove) the top [count] blocks from the blockchain. EXPERIMENTAL',
preventIfRunning: true,
onDatabaseExecute: (server, conf, program, params) => co(function*() {
const count = params[0];
const logger = server.logger;
......
......@@ -222,6 +222,12 @@ function Stack(dependencies) {
logger.error("Configuration could not be saved: " + e);
throw Error(e);
}
const daemon = server.getDaemon()
if (command.preventIfRunning && daemon.status()) {
throw 'Your node is currently running. Please stop it and relaunch your command.'
}
// First possible class of commands: post-config
if (command.onConfiguredExecute) {
return yield command.onConfiguredExecute(server, conf, program, params, wizardTasks, that);
......
......@@ -69,9 +69,9 @@
"devDependencies": {
"coveralls": "2.11.4",
"duniter-bma": "^1.0.7",
"duniter-crawler": "^1.0.7",
"duniter-crawler": "^1.0.8",
"duniter-keypair": "^1.0.1",
"duniter-prover": "^1.0.3",
"duniter-prover": "^1.0.4",
"eslint": "3.13.1",
"eslint-plugin-mocha": "4.8.0",
"istanbul": "0.4.0",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment