2023-12-25 05:08:41 +00:00
|
|
|
import { run } from "@ludus/ludus-js-pure"
|
2023-12-25 00:25:42 +00:00
|
|
|
|
2023-12-25 05:08:41 +00:00
|
|
|
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)
|
2023-12-25 00:25:42 +00:00
|
|
|
|
2023-12-25 05:08:41 +00:00
|
|
|
if (output.errors) {
|
|
|
|
for (const error of output.errors) {
|
|
|
|
console.log(error)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.log(output.result)
|
|
|
|
}
|
|
|
|
}
|