25 lines
526 B
Plaintext
Executable File
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() |