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,52 +1,39 @@
|
||||
//@ts-check
|
||||
const { exec, fork, spawn } = require('child_process');
|
||||
/**
|
||||
* @param {string} path
|
||||
* @deprecated
|
||||
*/
|
||||
function hookTo(path) {
|
||||
exec(`node ${path}`)
|
||||
}
|
||||
import { spawnSync, spawn } from 'bun'
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
*/
|
||||
async function fHook(path) {
|
||||
const child = fork(path)
|
||||
return new Promise((res, rej) => {
|
||||
child.on('exit', () => {
|
||||
res()
|
||||
})
|
||||
})
|
||||
export async function fHook(path) {
|
||||
return await spawnAndWait([ '/usr/bin/bun', 'run', path ])
|
||||
}
|
||||
|
||||
/**
|
||||
* @param { string } cmd
|
||||
* @param { import('child_process').SpawnOptionsWithoutStdio } [option]
|
||||
* @param { [string, ...string[]] } cmd
|
||||
* @param { import('bun').SpawnOptions.OptionsObject } [option]
|
||||
*/
|
||||
async function spawnAndWait(cmd, option) {
|
||||
const child = spawn(cmd, option)
|
||||
export async function spawnAndWait(cmd, option) {
|
||||
console.log('spawning ' + cmd.join(' '))
|
||||
return spawnSync(cmd, {
|
||||
...option,
|
||||
env: {
|
||||
PATH: "/bin:/sbin:/usr/bin:/usr/sbin",
|
||||
...process.env,
|
||||
...(option?.env || {})
|
||||
},
|
||||
|
||||
child.stdout.pipe(process.stdout)
|
||||
child.stderr.pipe(process.stderr)
|
||||
process.stdin.pipe(child.stdin)
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
child.on('exit', () => {
|
||||
res()
|
||||
})
|
||||
stdout: "inherit",
|
||||
stdin: "inherit",
|
||||
stderr: "inherit"
|
||||
})
|
||||
process.stdin.unpipe(child.stdin)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param { string } path
|
||||
* @param { string[] } [args]
|
||||
* @param { import('child_process').SpawnOptionsWithoutStdio } [options]
|
||||
* @param { import('bun').SpawnOptions.OptionsObject } [options]
|
||||
*/
|
||||
async function startjs(path, args = [], options = {}) {
|
||||
const arguments = args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg}).join(' ')
|
||||
return spawnAndWait(`/usr/local/bin/node ${path} ${arguments}`, options)
|
||||
export async function startjs(path, args = [], options = {}) {
|
||||
const SpawnArguments = args.map(arg => {return arg.includes(' ') ? `"${arg}"` : arg})
|
||||
return spawnAndWait(['/usr/bin/bun', path, ...SpawnArguments ], options)
|
||||
}
|
||||
|
||||
module.exports = { hookTo, fHook, spawnAndWait, startjs }
|
||||
Reference in New Issue
Block a user