From 81e75d9ca58e91e9ba171898f6e5d1c6a54650e0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 1 Jul 2014 07:31:04 -0400 Subject: [PATCH] feature(console) prompt: add current directory --- lib/client/console.js | 22 +++++++++++----------- lib/server/console.js | 6 ++++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index 73760505..e317ce86 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -46,6 +46,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; this.show = show; + // Handle a command. + function handler(command) { + if (command) + Socket.emit(CHANNEL, command); + } + function show(callback) { if (!Loading) { Images.showLoad({top:true}); @@ -62,17 +68,6 @@ var CloudCmd, Util, DOM, CloudFunc, $; jqconsole.AbortPrompt(); handler(); }); - - // Handle a command. - var handler = function(command) { - if (command) - Socket.emit(CHANNEL, command); - - jqconsole.Prompt(true, handler); - }; - - // Initiate the first prompt. - handler(); } CloudCmd.View.show(Element, { @@ -175,7 +170,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; log(json.stdout); error(json.stderr); + + if (json.path) + jqconsole.SetPromptLabel(json.path + '>'); } + + jqconsole.Prompt(true, handler); } init(); diff --git a/lib/server/console.js b/lib/server/console.js index 19143e1d..525c0c37 100644 --- a/lib/server/console.js +++ b/lib/server/console.js @@ -72,10 +72,12 @@ if (!Clients[ConNum]) { msg = log(ConNum, 'console connected'); - Util.exec(callback, { - stdout : addNewLine(msg) + callback({ + stdout : addNewLine(msg), + path : process.cwd() }); + Clients[ConNum] = true; onMessage = Util.exec.with(getOnMessage, ConNum, callback);