mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
fix(cockpit/console): fix cockpit's console outputting "console >"
This commit is contained in:
parent
785edf4c9d
commit
22e771bbda
@ -346,7 +346,9 @@ class EmbarkController {
|
|||||||
new REPL({
|
new REPL({
|
||||||
events: engine.events,
|
events: engine.events,
|
||||||
env: engine.env,
|
env: engine.env,
|
||||||
ipc: engine.ipc
|
ipc: engine.ipc,
|
||||||
|
useDashboard: false,
|
||||||
|
logger: engine.logger
|
||||||
}).start(callback);
|
}).start(callback);
|
||||||
}
|
}
|
||||||
], function (err, _result) {
|
], function (err, _result) {
|
||||||
|
@ -25,7 +25,7 @@ class Dashboard {
|
|||||||
start(done) {
|
start(done) {
|
||||||
let monitor;
|
let monitor;
|
||||||
|
|
||||||
monitor = new Monitor({env: this.env, events: this.events, version: this.version, ipc: this.ipc});
|
monitor = new Monitor({env: this.env, events: this.events, version: this.version, ipc: this.ipc, logger: this.logger});
|
||||||
this.logger.logFunction = monitor.logEntry;
|
this.logger.logFunction = monitor.logEntry;
|
||||||
let plugin = this.plugins.createPlugin('dashboard', {});
|
let plugin = this.plugins.createPlugin('dashboard', {});
|
||||||
plugin.registerAPICall(
|
plugin.registerAPICall(
|
||||||
|
@ -9,6 +9,7 @@ class Monitor {
|
|||||||
this.env = options.env;
|
this.env = options.env;
|
||||||
this.console = options.console;
|
this.console = options.console;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
|
this.logger = options.logger;
|
||||||
this.color = options.color || "green";
|
this.color = options.color || "green";
|
||||||
this.minimal = options.minimal || false;
|
this.minimal = options.minimal || false;
|
||||||
this.ipc = options.ipc;
|
this.ipc = options.ipc;
|
||||||
@ -56,7 +57,9 @@ class Monitor {
|
|||||||
inputStream: this.terminalReadableStream,
|
inputStream: this.terminalReadableStream,
|
||||||
outputStream: terminalWritableStream,
|
outputStream: terminalWritableStream,
|
||||||
logText: this.logText,
|
logText: this.logText,
|
||||||
ipc: this.ipc
|
ipc: this.ipc,
|
||||||
|
useDashboard: true,
|
||||||
|
logger: this.logger
|
||||||
}).start(() => {
|
}).start(() => {
|
||||||
this.terminal.focus();
|
this.terminal.focus();
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,8 @@ class REPL {
|
|||||||
this.outputStream = options.outputStream || process.stdout;
|
this.outputStream = options.outputStream || process.stdout;
|
||||||
this.logText = options.logText;
|
this.logText = options.logText;
|
||||||
this.ipc = options.ipc;
|
this.ipc = options.ipc;
|
||||||
|
this.logger = options.logger;
|
||||||
|
this.useDashboard = options.useDashboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
addHistory(cmd) {
|
addHistory(cmd) {
|
||||||
@ -19,6 +21,9 @@ class REPL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enhancedEval(cmd, context, filename, callback) {
|
enhancedEval(cmd, context, filename, callback) {
|
||||||
|
if (this.useDashboard) {
|
||||||
|
this.logger.consoleOnly("console> ".cyan + cmd.white);
|
||||||
|
}
|
||||||
this.events.request('console:executeCmd', cmd.trim(), function (err, message) {
|
this.events.request('console:executeCmd', cmd.trim(), function (err, message) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// Do not return as the first param (error), because the dashboard doesn't print errors
|
// Do not return as the first param (error), because the dashboard doesn't print errors
|
||||||
|
@ -176,8 +176,7 @@ class Engine {
|
|||||||
version: this.version,
|
version: this.version,
|
||||||
ipc: this.ipc,
|
ipc: this.ipc,
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
config: this.config,
|
config: this.config
|
||||||
useDashboard: this.useDashboard
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,14 @@ Logger.prototype.info = function () {
|
|||||||
this.writeToFile("[info]: ", ...arguments);
|
this.writeToFile("[info]: ", ...arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Logger.prototype.consoleOnly = function () {
|
||||||
|
if (!arguments.length || !(this.shouldLog('info'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.logFunction(...Array.from(arguments), 'green');
|
||||||
|
this.writeToFile("[consoleOnly]: ", ...arguments);
|
||||||
|
};
|
||||||
|
|
||||||
Logger.prototype.debug = function () {
|
Logger.prototype.debug = function () {
|
||||||
if (!arguments.length || !(this.shouldLog('debug'))) {
|
if (!arguments.length || !(this.shouldLog('debug'))) {
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,6 @@ class Console {
|
|||||||
private cmdHistoryFile: string;
|
private cmdHistoryFile: string;
|
||||||
private suggestions?: Suggestions;
|
private suggestions?: Suggestions;
|
||||||
private providerReady: boolean;
|
private providerReady: boolean;
|
||||||
private useDashboard: boolean;
|
|
||||||
|
|
||||||
constructor(embark: Embark, options: any) {
|
constructor(embark: Embark, options: any) {
|
||||||
this.embark = embark;
|
this.embark = embark;
|
||||||
@ -41,7 +40,6 @@ class Console {
|
|||||||
this.fs = embark.fs;
|
this.fs = embark.fs;
|
||||||
this.ipc = options.ipc;
|
this.ipc = options.ipc;
|
||||||
this.config = options.config;
|
this.config = options.config;
|
||||||
this.useDashboard = options.useDashboard;
|
|
||||||
this.history = [];
|
this.history = [];
|
||||||
this.cmdHistoryFile = options.cmdHistoryFile || this.fs.dappPath(".embark", "cmd_history");
|
this.cmdHistoryFile = options.cmdHistoryFile || this.fs.dappPath(".embark", "cmd_history");
|
||||||
this.providerReady = false;
|
this.providerReady = false;
|
||||||
@ -153,9 +151,6 @@ class Console {
|
|||||||
return this.ipc.request("console:executeCmd", cmd, callback);
|
return this.ipc.request("console:executeCmd", cmd, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.useDashboard) {
|
|
||||||
this.logger.info("console > ".cyan + cmd.white);
|
|
||||||
}
|
|
||||||
if (!(cmd.split(" ")[0] === "history" || cmd === __("history"))) {
|
if (!(cmd.split(" ")[0] === "history" || cmd === __("history"))) {
|
||||||
this.saveHistory(cmd);
|
this.saveHistory(cmd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user