foam/bin/foam
Chris Wanstrath 67f8b4b25c 🫧 foam
2025-11-03 16:41:02 -08:00

25 lines
526 B
Plaintext
Executable File

#!/usr/bin/env bun
import { statSync } from 'fs'
import { join } from 'path'
import { fileURLToPath } from 'url'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const { startWeb } = await import(join(__dirname, '../src/server.ts'))
function main() {
const root = Bun.argv[2]
if (!isDir(root)) {
console.error('usage: foam <directory>')
process.exit(1)
}
startWeb(root)
}
function isDir(path: string): boolean {
try { return statSync(path).isDirectory() } catch { return false }
}
main()