hackmud-script-manager 0.20.4-a5e6bcd → 0.20.4-a7d8309
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -0
- package/bin/hsm.js +223 -253
- package/env.d.ts +315 -310
- package/generateTypeDeclaration.js +2 -1
- package/index.js +2 -1
- package/package.json +38 -38
- package/processScript/index.js +2 -2
- package/processScript/minify.js +5 -14
- package/processScript/preprocess.js +5 -3
- package/processScript/transform.js +87 -84
- package/push.js +4 -4
- package/watch.js +9 -7
package/watch.js
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
import {
|
1
|
+
import { AutoMap } from "@samual/lib/AutoMap"
|
2
2
|
import { assert } from "@samual/lib/assert"
|
3
3
|
import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
|
4
4
|
import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
|
5
5
|
import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
|
6
6
|
import { watch as watch$1 } from "chokidar"
|
7
|
-
import { readFile, writeFile } from "fs/promises"
|
7
|
+
import { stat, readFile, writeFile } from "fs/promises"
|
8
8
|
import { extname, basename, resolve } from "path"
|
9
9
|
import { supportedExtensions } from "./constants.js"
|
10
10
|
import { generateTypeDeclaration } from "./generateTypeDeclaration.js"
|
11
11
|
import { processScript } from "./processScript/index.js"
|
12
|
+
import "path/posix"
|
12
13
|
import "@babel/generator"
|
13
14
|
import "@babel/parser"
|
14
15
|
import "@babel/plugin-proposal-decorators"
|
@@ -58,7 +59,8 @@ async function watch(
|
|
58
59
|
} = {}
|
59
60
|
) {
|
60
61
|
if (!scripts.length) throw Error("scripts option was an empty array")
|
61
|
-
|
62
|
+
if (!(await stat(sourceDirectory)).isDirectory()) throw Error("Target folder must be a folder")
|
63
|
+
const scriptNamesToUsers = new AutoMap(_scriptName => new Set()),
|
62
64
|
wildScriptUsers = new Set(),
|
63
65
|
wildUserScripts = new Set()
|
64
66
|
let pushEverything = !1
|
@@ -90,7 +92,7 @@ async function watch(
|
|
90
92
|
)
|
91
93
|
)
|
92
94
|
return
|
93
|
-
const scriptNamesToUsersToSkip = new
|
95
|
+
const scriptNamesToUsersToSkip = new AutoMap(_scriptName => [])
|
94
96
|
await Promise.all(
|
95
97
|
(await readDirectoryWithStats(sourceDirectory)).map(async ({ stats, name, path }) => {
|
96
98
|
if (stats.isDirectory())
|
@@ -135,7 +137,7 @@ async function watch(
|
|
135
137
|
forceQuineCheats
|
136
138
|
}))
|
137
139
|
} catch (error) {
|
138
|
-
assert(error instanceof Error, "src/watch.ts:
|
140
|
+
assert(error instanceof Error, "src/watch.ts:146:36")
|
139
141
|
onPush?.({ path, users: [], characterCount: 0, error })
|
140
142
|
return
|
141
143
|
}
|
@@ -180,7 +182,7 @@ async function watch(
|
|
180
182
|
forceQuineCheats
|
181
183
|
}))
|
182
184
|
} catch (error) {
|
183
|
-
assert(error instanceof Error, "src/watch.ts:
|
185
|
+
assert(error instanceof Error, "src/watch.ts:182:35")
|
184
186
|
onPush?.({ path, users: [], characterCount: 0, error })
|
185
187
|
return
|
186
188
|
}
|
@@ -195,7 +197,7 @@ async function watch(
|
|
195
197
|
try {
|
196
198
|
await writeFile(typeDeclarationPath, typeDeclaration)
|
197
199
|
} catch (error) {
|
198
|
-
assert(error instanceof Error, "src/watch.ts:
|
200
|
+
assert(error instanceof Error, "src/watch.ts:215:35")
|
199
201
|
if ("EISDIR" != error.code) throw error
|
200
202
|
typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
|
201
203
|
await writeFile(typeDeclarationPath, typeDeclaration)
|