chore: rewrite loadprg & fix some issues
This commit is contained in:
@@ -4,7 +4,21 @@ import { Program } from './Program'
|
||||
|
||||
export class Eval extends Program {
|
||||
async Exec(stdin: SimpleStream<string>, stdout: SimpleStream<string>, _workdir: Item, args: string[]): Promise<number> {
|
||||
let javascript: string = args.slice(1).join(' ')
|
||||
const inlineArgs = args.slice(1)
|
||||
const source = inlineArgs.length > 0
|
||||
? inlineArgs.join(' ')
|
||||
: await stdin.wait()
|
||||
|
||||
if (source.trim().length === 0) {
|
||||
stdout.emit('eval: error: missing javascript input\n')
|
||||
return 1
|
||||
}
|
||||
|
||||
try {
|
||||
this.RunJs(source, stdout)
|
||||
} catch {
|
||||
return 1
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user