Reorganisation de tout le systéme de build + debuggage os loader au autre scripts
This commit is contained in:
@@ -4,28 +4,7 @@ const { getline } = require('../lib/sheebr/utils')
|
||||
const fs = require('fs')
|
||||
let environment = require('../lib/sheebr/environment')
|
||||
let aliases = require("../lib/sheebr/aliases")
|
||||
let { spawn } = require('child_process')
|
||||
|
||||
//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
|
||||
/**
|
||||
* @param { string } cmd
|
||||
* @param { import('child_process').SpawnOptionsWithoutStdio } [option]
|
||||
*/
|
||||
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) => {
|
||||
child.on('exit', () => {
|
||||
res()
|
||||
})
|
||||
})
|
||||
process.stdin.unpipe(child.stdin)
|
||||
}
|
||||
|
||||
const { startjs } = require('../../core/hook')
|
||||
|
||||
let current_dir = process.cwd()
|
||||
|
||||
@@ -90,7 +69,9 @@ async function evaluateProgram(args){
|
||||
if(files.includes(`${args[0]}.js`)){
|
||||
found = true;
|
||||
try {
|
||||
await spawnAndWait(`${environment.node} ${path + '/' + args[0]}.js ${args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ')}`, {cwd: current_dir, env: environment, shell: true});
|
||||
const cmd = `${path + '/' + args[0]}.js`
|
||||
const options = {cwd: current_dir, env: environment, shell: true}
|
||||
await startjs(cmd, args, options)
|
||||
tobreak = true;
|
||||
} catch(e) {
|
||||
console.log("Program crashed")
|
||||
|
||||
@@ -9,7 +9,6 @@ let environment = {
|
||||
ln: [1, 36],
|
||||
ex: [1, 32]
|
||||
}),
|
||||
node: "/usr/local/bin/node"
|
||||
}
|
||||
|
||||
module.exports = environment
|
||||
Reference in New Issue
Block a user