ChibraxOS 2
Changes: - kernel 6.0.2 - Broken init scripts - Switch to bun for better peroformance an easier ffi - Removed grup - Efi support without graphics (at least graphics werent tested) - Suppression de toutes les dépendance non libc - new splash - broken audio - typescript support - ls rewritten to be more reliable
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
//@ts-check
|
||||
const { Lexer } = require('../lib/sheebr/lexer')
|
||||
const { getline } = require('../lib/sheebr/utils')
|
||||
const fs = require('fs')
|
||||
let environment = require('../lib/sheebr/environment')
|
||||
let aliases = require("../lib/sheebr/aliases")
|
||||
const { startjs } = require('../../core/hook')
|
||||
|
||||
import { startjs } from '../../core/hook'
|
||||
import Lexer from '../lib/sheebr/lexer'
|
||||
import * as fs from 'fs'
|
||||
import environment from '../lib/sheebr/environment'
|
||||
import aliases from '../lib/sheebr/aliases'
|
||||
import * as path from 'path'
|
||||
|
||||
let current_dir = process.cwd()
|
||||
|
||||
@@ -12,9 +13,13 @@ start()
|
||||
|
||||
async function start(){
|
||||
while(true){
|
||||
const input = await getline("sheebr> ");
|
||||
const input = prompt("sheebr> ");
|
||||
if(input === "exit") break;
|
||||
if(!input) continue;
|
||||
if(!input) {
|
||||
//work around missing line break
|
||||
console.log()
|
||||
continue
|
||||
}
|
||||
else await evaluate(input);
|
||||
}
|
||||
}
|
||||
@@ -61,23 +66,30 @@ async function evaluate(input){
|
||||
* @param {string[]} args
|
||||
*/
|
||||
async function evaluateProgram(args){
|
||||
|
||||
let found = false;
|
||||
for(let path of environment.path.split(':')){
|
||||
for(const envPath of environment.path.split(':')){
|
||||
let tobreak = false;
|
||||
const files = fs.readdirSync(path);
|
||||
if(files.includes(`${args[0]}.js`)){
|
||||
if(!fs.existsSync(envPath)) continue
|
||||
|
||||
const jsPath = path.join(envPath, `${args[0]}.js`)
|
||||
const tsPath = path.join(envPath, `${args[0]}.ts`)
|
||||
|
||||
console.log(jsPath, tsPath, envPath)
|
||||
|
||||
if(fs.existsSync(jsPath) || fs.existsSync(tsPath) ){
|
||||
found = true;
|
||||
console.log('found it: ' + path + args[0])
|
||||
try {
|
||||
const cmd = `${path + '/' + args[0]}.js`
|
||||
const cmd = fs.existsSync(jsPath) ? jsPath : tsPath
|
||||
const options = {cwd: current_dir, env: environment, shell: true}
|
||||
console.log(args)
|
||||
await startjs(cmd, args, options)
|
||||
tobreak = true;
|
||||
console.log('\x1b[0m')
|
||||
tobreak = true
|
||||
} catch(e) {
|
||||
console.log("Program crashed")
|
||||
}
|
||||
}
|
||||
|
||||
if(tobreak) break;
|
||||
}
|
||||
if(!found){
|
||||
@@ -114,4 +126,4 @@ function evaluateAliases(args){
|
||||
return aliases[args[0]].concat(args.slice(1))
|
||||
}
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user