-
-
Notifications
You must be signed in to change notification settings - Fork 97
/
cmd.ts
31 lines (28 loc) · 760 Bytes
/
cmd.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { $ } from "bun"
import Watcher from "watcher"
async function main() {
const args = Bun.argv
const command = args[2]
const currentFilePath = import.meta.url.replace("file://", "")
const currentFolder = `${currentFilePath.replace("cmd.ts", "")}`
const watcher = new Watcher(currentFolder, { recursive: true })
switch (command) {
case "run":
watcher.on("change", async (event) => {
if (event.endsWith(".ts")) {
await $`tput reset && bun ${event}`
}
})
if (args[3]) {
await $`tput reset && bun scripts/${args[3]}.ts`
}
break
case undefined:
console.log("No command provided")
break
default:
console.log("Unknown command")
break
}
}
main()