hackmud-script-manager 0.19.1-cb8d65f → 0.19.1-d57be2a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,14 @@
1
1
  import type { LaxPartial } from "@samual/lib";
2
2
  import type { PushOptions } from "./push";
3
- export type WatchOptions = PushOptions & {
3
+ export type WatchOptions = PushOptions & LaxPartial<{
4
4
  /** if provided, will write typescript type declarations for all the scripts on every change detected
5
5
  *
6
6
  * writing the type declarations enables interscript type checking and autocompletetes for the args */
7
7
  typeDeclarationPath: string;
8
8
  onReady: () => void;
9
- };
9
+ }>;
10
10
  /** Watches target file or folder for updates and builds and pushes updated file.
11
11
  * @param sourceDirectory path to folder containing source files
12
12
  * @param hackmudDirectory path to hackmud directory
13
13
  * @param options {@link WatchOptions details} and {@link PushOptions more details} */
14
- export declare function watch(sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, typeDeclarationPath: typeDeclarationPath_, onReady, forceQuineCheats }?: LaxPartial<WatchOptions>): Promise<void>;
15
- export default watch;
14
+ export declare function watch(sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, typeDeclarationPath: typeDeclarationPath_, onReady, forceQuineCheats }?: WatchOptions): Promise<void>;
package/watch.js CHANGED
@@ -116,7 +116,7 @@ async function watch(
116
116
  for (const user of scriptNamesToUsers.get(scriptName)) usersToPushToSet.add(user)
117
117
  const usersToPushTo = [...usersToPushToSet].filter(user => !scriptNamesToUsersToSkip.has(user))
118
118
  if (!usersToPushTo.length) {
119
- onPush?.({ file: path, users: [], minLength: 0, error: Error("no users to push to") })
119
+ onPush?.({ path, users: [], characterCount: 0, error: Error("no users to push to") })
120
120
  return
121
121
  }
122
122
  const uniqueID = Math.floor(Math.random() * 2 ** 52)
@@ -125,7 +125,7 @@ async function watch(
125
125
  filePath = resolve(sourceDirectory, path)
126
126
  let minifiedCode
127
127
  try {
128
- ;({ script: minifiedCode } = await processScript(await readFile(filePath, { encoding: "utf-8" }), {
128
+ ;({ script: minifiedCode } = await processScript(await readFile(filePath, { encoding: "utf8" }), {
129
129
  minify,
130
130
  scriptUser: !0,
131
131
  scriptName,
@@ -136,7 +136,7 @@ async function watch(
136
136
  }))
137
137
  } catch (error) {
138
138
  assert(error instanceof Error, "src/watch.ts:141:36")
139
- onPush?.({ file: path, users: [], minLength: 0, error })
139
+ onPush?.({ path, users: [], characterCount: 0, error })
140
140
  return
141
141
  }
142
142
  await Promise.all(
@@ -150,9 +150,9 @@ async function watch(
150
150
  )
151
151
  )
152
152
  onPush?.({
153
- file: path,
153
+ path,
154
154
  users: usersToPushTo,
155
- minLength: countHackmudCharacters(minifiedCode),
155
+ characterCount: countHackmudCharacters(minifiedCode),
156
156
  error: void 0
157
157
  })
158
158
  return
@@ -168,7 +168,7 @@ async function watch(
168
168
  )
169
169
  return
170
170
  const filePath = resolve(sourceDirectory, path),
171
- sourceCode = await readFile(filePath, { encoding: "utf-8" })
171
+ sourceCode = await readFile(filePath, { encoding: "utf8" })
172
172
  let script
173
173
  try {
174
174
  ;({ script } = await processScript(sourceCode, {
@@ -181,11 +181,11 @@ async function watch(
181
181
  }))
182
182
  } catch (error) {
183
183
  assert(error instanceof Error, "src/watch.ts:177:35")
184
- onPush?.({ file: path, users: [], minLength: 0, error })
184
+ onPush?.({ path, users: [], characterCount: 0, error })
185
185
  return
186
186
  }
187
187
  await writeFilePersistent(resolve(hackmudDirectory, user, "scripts", scriptName + ".js"), script)
188
- onPush?.({ file: path, users: [user], minLength: countHackmudCharacters(script), error: void 0 })
188
+ onPush?.({ path, users: [user], characterCount: countHackmudCharacters(script), error: void 0 })
189
189
  })
190
190
  onReady && watcher.on("ready", onReady)
191
191
  if (!typeDeclarationPath_) return
@@ -205,4 +205,4 @@ async function watch(
205
205
  watcher.on("add", writeTypeDeclaration)
206
206
  watcher.on("unlink", writeTypeDeclaration)
207
207
  }
208
- export { watch as default, watch }
208
+ export { watch }
File without changes
File without changes