21 lines
424 B
TypeScript
21 lines
424 B
TypeScript
#!/usr/bin/env bun
|
|
|
|
import { renderMarkdown } from "./index"
|
|
|
|
const args = process.argv.slice(2)
|
|
|
|
let input: string
|
|
|
|
if (args.length > 0 && args[0] !== "-") {
|
|
const file = Bun.file(args[0])
|
|
if (!(await file.exists())) {
|
|
process.stderr.write(`tm: ${args[0]}: No such file\n`)
|
|
process.exit(1)
|
|
}
|
|
input = await file.text()
|
|
} else {
|
|
input = await Bun.stdin.text()
|
|
}
|
|
|
|
process.stdout.write(renderMarkdown(input))
|