refacto ts + ajout de dessin simple + ajout pinceau
WIP lib graphique
This commit is contained in:
@@ -7,6 +7,10 @@ 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)
|
||||
|
||||
@@ -36,6 +40,10 @@ async function start(){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param { string } input
|
||||
* @returns
|
||||
*/
|
||||
async function evaluate(input){
|
||||
let lexer = new Lexer(input)
|
||||
let args = lexer.scanTokens()
|
||||
@@ -70,12 +78,13 @@ async function evaluate(input){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {string[]} args
|
||||
*/
|
||||
async function evaluateProgram(args){
|
||||
|
||||
let found = false;
|
||||
for(let path of environment.path){
|
||||
for(let path of environment.path.split(':')){
|
||||
let tobreak = false;
|
||||
const files = fs.readdirSync(path);
|
||||
if(files.includes(`${args[0]}.js`)){
|
||||
@@ -95,6 +104,10 @@ async function evaluateProgram(args){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} args
|
||||
* @returns
|
||||
*/
|
||||
function evaluateEnvironmentVariables(args){
|
||||
let newArgs = []
|
||||
for(let arg of args){
|
||||
@@ -111,6 +124,10 @@ function evaluateEnvironmentVariables(args){
|
||||
return newArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param { string[] } args
|
||||
* @returns
|
||||
*/
|
||||
function evaluateAliases(args){
|
||||
if(args[0] in aliases){
|
||||
return aliases[args[0]].concat(args.slice(1))
|
||||
|
||||
Reference in New Issue
Block a user