Skip to content

Commit 0555b20

Browse files
committed
added command to generate typings
also added option to watch command
1 parent fa87752 commit 0555b20

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/hsm.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readFile, mkdir as mkDir, writeFile, rmdir as rmDir } from "fs/promises"
22
import { resolve as resolvePath } from "path"
33
import { homedir as homeDir } from "os"
4-
import { pull, push, syncMacros, test, watch } from ".."
4+
import { generateTypings, pull, push, syncMacros, test, watch } from ".."
55
import { redBright, yellowBright, greenBright, blueBright, cyanBright, magentaBright, bold, dim } from "ansi-colors"
66

77
// let o = ""
@@ -124,6 +124,7 @@ for (let arg of process.argv.slice(2)) {
124124
const scripts = options.get("scripts")?.toString().split(",") || []
125125
const colours = [ redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright ]
126126
const configUsers = config.users = config.users || {}
127+
const genTypes = options.get("gen-types")?.toString()
127128

128129
watch(
129130
srcPath,
@@ -142,7 +143,8 @@ for (let arg of process.argv.slice(2)) {
142143
(configUsers[user] = configUsers[user] || { colour: colours[Math.floor(Math.random() * colours.length)](user) }).colour
143144
).join(", ")
144145
} [${minLength} chars]`
145-
)
146+
),
147+
{ genTypes }
146148
)
147149
} else
148150
console.log("you need to set hackmudPath in config before you can use this command")
@@ -205,6 +207,20 @@ for (let arg of process.argv.slice(2)) {
205207
break
206208
}
207209

210+
case "gen-types": {
211+
const srcPath = resolvePath(commands[1] || ".")
212+
let targetPath: string
213+
214+
if (commands[2])
215+
targetPath = resolvePath(commands[2])
216+
else
217+
targetPath = resolvePath(srcPath, "../player.d.ts")
218+
219+
generateTypings(srcPath, targetPath, (await getConfig()).hackmudPath)
220+
221+
break
222+
}
223+
208224
case "config":
209225
switch (commands[1]) {
210226
case "get":

0 commit comments

Comments
 (0)