fix bug stdin pipe to wrong process

This commit is contained in:
Marc
2022-01-26 14:15:25 +01:00
parent 5e116fb3ac
commit 8c0c34af27
2 changed files with 13 additions and 5 deletions
+5 -3
View File
@@ -6,11 +6,12 @@ let environment = require('../lib/sheebr/environment')
let aliases = require("../lib/sheebr/aliases")
let { spawn } = require('child_process')
//utiliser ce code au lieuxc de execSync permet d'afficher le stdout au fur et a mesure ce qui fait qu'on a les logs quand une application throw une erreur
//utiliser ce code au lieux de execSync permet d'afficher le stdout au fur et a mesure ce qui fait qu'on a les logs quand une application throw une erreur
async function spawnAndWait(cmd, option) {
const child = spawn(cmd, option)
child.stdout.pipe(process.stdout)
child.stderr.pipe(process.stderr)
process.stdin.pipe(child.stdin)
await new Promise((res, rej) => {
@@ -18,6 +19,7 @@ async function spawnAndWait(cmd, option) {
res()
})
})
process.stdin.unpipe(child.stdin)
}
@@ -28,8 +30,8 @@ start()
async function start(){
while(true){
const input = await getline("sheebr> ");
if(input == "exit") break;
if(input == "") continue;
if(input === "exit") break;
if(!input) continue;
else await evaluate(input);
}
}