From 55dd8e7db3ad2df8a335abbbf8a6460c09dec683 Mon Sep 17 00:00:00 2001 From: joshua mshana Date: Sun, 14 Feb 2021 19:09:48 +0300 Subject: [PATCH] remove bash codes from returned back to user terminal --- functions/events/terminal.event.mjs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/functions/events/terminal.event.mjs b/functions/events/terminal.event.mjs index 802fda1..48e53a8 100644 --- a/functions/events/terminal.event.mjs +++ b/functions/events/terminal.event.mjs @@ -28,12 +28,17 @@ function initiateTerm(project, path, response,) { if (ending === true) { ending = false; } else { - response.broadcast(data); + const value = data.toString().match(new RegExp('.*@.*:.*~.*\\$')); + if (value) { + response.broadcast(END_OF_LINE); + } else { + response.broadcast(data); + } } } }); terminals[project].on('exit', _ => { - response.broadcast(END_OF_LINE); + // response.broadcast(END_OF_LINE); }); } else { // console.log(`terminal of ${project} already initialized pid --> ` + terminals[project].pid); @@ -43,8 +48,12 @@ function initiateTerm(project, path, response,) { async function execCommand(cmd, project, response) { const projectPath = await storage.getConfig(`${project}:projectPath`); initiateTerm(project, projectPath, response); - if (cmd === 'start') { - terminals[project].write('npm start \r'); + if (cmd.toString().trim().startsWith('start')) { + let port = cmd.toString().replace('start', '').trim(); + if (port === '') { + port = '4200'; + } + terminals[project].write(`npx ng serve --port ${port} \r`); } else if (cmd === 'build') { terminals[project].write('npx ng build --prod \r'); } else if (cmd.toString().startsWith('install')) { @@ -53,7 +62,7 @@ async function execCommand(cmd, project, response) { terminals[project].write('\x03'); terminals[project] = undefined; } else { - response.emit('bad command --> ' + cmd); + response.emit('unknown command --> ' + cmd); response.emit(END_OF_LINE); } }