sync: wip changes

This commit is contained in:
binekrasik
2026-05-22 14:48:00 +02:00
parent 62038c2814
commit 4777552106
3 changed files with 23 additions and 31 deletions

View File

@@ -3,17 +3,19 @@ import type { SimpleStream } from '../utils/SimpleStream'
import { Program } from './Program'
export class Eval extends Program {
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
const javascript = args.slice(1).join(' ')
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
let javascript: string = args.slice(1).join(' ')
return 0
}
private RunJs(javascript: string, stdout: SimpleStream<string>) {
try {
// todo: pass workdir to the program
eval(javascript)
} catch (e) {
stdout.emit(`${String(e)}\n`)
return 1
throw e
}
return 0
}
}

View File

@@ -11,9 +11,11 @@ export class Loadprg extends Program {
this.shell = shell
}
async Exec(_: SimpleStream<string>, stdout: SimpleStream<string>, __: Item, args: string[]): Promise<number> {
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, __: Item, args: string[]): Promise<number> {
const javascript = args.slice(2).join(' ')
stdin.on(data => stdout.emit(`loadprg stdin: ${data}\x1B[0;30m\x1B[47m<- EOF\x1B[0m\n`))
try {
const program = eval(javascript)