fix(debugger): fix and improve console commands

This commit is contained in:
Jonathan Rainville 2018-12-06 16:01:29 -05:00 committed by Iuri Matias
parent 5b6b582459
commit 37c28b9727

View File

@ -1,5 +1,7 @@
import DebuggerManager from "./debugger_manager";
const NO_DEBUG_SESSION = __("No debug session active. Activate one with `debug`");
interface Events {
on: any;
request: any;
@ -249,15 +251,21 @@ class TransactionDebugger {
return {
match: () => (cmd === "next" || cmd === "n"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
if (!this.cmdDebugger.canGoNext()) {
return;
return cb();
}
if (!this.cmdDebugger.currentStep()) {
this.embark.logger.info("end of execution reached");
return this.cmdDebugger.unload();
this.cmdDebugger.unload();
return cb();
}
this.cmdDebugger.stepOverForward(true);
this.displayStepInfo();
cb();
},
};
});
@ -266,8 +274,12 @@ class TransactionDebugger {
return {
match: () => (cmd === "previous" || cmd === "p"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
if (!this.cmdDebugger.canGoPrevious()) {
return;
return cb();
}
if (!this.cmdDebugger.currentStep()) {
this.embark.logger.info("end of execution reached");
@ -275,6 +287,7 @@ class TransactionDebugger {
}
this.cmdDebugger.stepOverBack(true);
this.displayStepInfo();
cb();
},
};
});
@ -283,7 +296,12 @@ class TransactionDebugger {
return {
match: () => (cmd === "var local" || cmd === "v l" || cmd === "vl"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
this.cmdDebugger.displayLocals();
cb();
},
};
});
@ -292,7 +310,12 @@ class TransactionDebugger {
return {
match: () => (cmd === "var global" || cmd === "v g" || cmd === "vg"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
this.cmdDebugger.displayGlobals();
cb();
},
};
});
@ -301,9 +324,17 @@ class TransactionDebugger {
return {
match: () => (cmd === "var all" || cmd === "v a" || cmd === "va"),
process: (cb: any) => {
if (!this.cmdDebugger) {
this.embark.logger.warn(NO_DEBUG_SESSION);
return cb();
}
this.getGlobals(this.currentCmdTxHash, (err: any, globals: any) => {
if (err) { return this.embark.logger.error(err); }
if (err) {
this.embark.logger.error(err);
return cb();
}
this.embark.logger.info(globals);
cb();
});
},
};