ludus-repl/runner.ts

21 lines
473 B
TypeScript
Raw Permalink Normal View History

import { run } from "@ludus/ludus-js-pure"
export async function run_file (path: string): Promise<void> {
const handle = Bun.file(path)
const file_exists = await handle.exists()
if (!file_exists) {
console.log(`File not found: ${path}`)
return
}
const source = await handle.text()
const output = run(source)
if (output.errors) {
for (const error of output.errors) {
console.log(error)
}
} else {
console.log(output.result)
}
}