hackmud-script-manager 0.20.4-52a588b → 0.20.4-66e0e13

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.
package/bin/hsm.js CHANGED
@@ -24,16 +24,16 @@ const formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
24
24
  log = message => console.log(colourS(message))
25
25
  for (const argument of process.argv.slice(2))
26
26
  if ("-" == argument[0]) {
27
- const [key, valueRaw] = argument.split("=")
28
- let value = valueRaw
29
- if (value)
30
- if ("true" == value) value = !0
31
- else if ("false" == value) value = !1
32
- else {
33
- const number = Number(value)
34
- isFinite(number) && (value = number)
35
- }
36
- else value = !0
27
+ const argumentEqualsIndex = argument.indexOf("=")
28
+ let key, value
29
+ if (-1 == argumentEqualsIndex) {
30
+ key = argument
31
+ value = !0
32
+ } else {
33
+ key = argument.slice(0, argumentEqualsIndex)
34
+ value = argument.slice(argumentEqualsIndex + 1)
35
+ "true" == value ? (value = !0) : "false" == value && (value = !1)
36
+ }
37
37
  if ("-" == argument[1]) options.set(key.slice(2), value)
38
38
  else for (const option of key.slice(1)) options.set(option, value)
39
39
  } else commands.push(argument)
@@ -58,13 +58,14 @@ const pushModule = import("../push.js"),
58
58
  process.version.startsWith("v21.") &&
59
59
  console.warn(
60
60
  colourF(
61
- "Warning: Support for Node.js 21 will be dropped in the next minor version of HSM\n You should update your version of Node.js\n https://nodejs.org/en/download/package-manager"
61
+ `Warning: Support for Node.js 21 will be dropped in the next minor version of HSM\n Your current version of Node.js is ${chalk.bold(process.version)}\n You should update your version of Node.js\n https://nodejs.org/en/download/package-manager\n`
62
62
  )
63
63
  )
64
64
  if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
65
- console.log("0.20.4-52a588b")
65
+ console.log("0.20.4-66e0e13")
66
66
  process.exit()
67
67
  }
68
+ let warnedDeprecatedEmitDtsAlias = !1
68
69
  if (popOption("help", "h")?.value) {
69
70
  logHelp()
70
71
  process.exit()
@@ -77,10 +78,18 @@ switch (commands[0]) {
77
78
  case "golf":
78
79
  case "minify":
79
80
  {
80
- const noMinifyOption = popOption("no-minify", "skip-minify"),
81
- mangleNamesOption = popOption("mangle-names"),
81
+ const noMinifyOption = popOption("no-minify", "skip-minify")
82
+ noMinifyOption &&
83
+ "no-minify" != noMinifyOption.name &&
84
+ console.warn(
85
+ colourF(
86
+ `Warning: ${formatOption(noMinifyOption.name)} is deprecated and will be removed in the next minor\n release of HSM\n You should switch to using its alias ${colourN("--no-minify")}\n`
87
+ )
88
+ )
89
+ const mangleNamesOption = popOption("mangle-names"),
82
90
  forceQuineCheatsOption = popOption("force-quine-cheats"),
83
- noMinifyIncompatibleOption = mangleNamesOption || forceQuineCheatsOption
91
+ noQuineCheatsOptions = popOption("no-quine-cheats"),
92
+ noMinifyIncompatibleOption = mangleNamesOption || forceQuineCheatsOption || noQuineCheatsOptions
84
93
  if (noMinifyOption && noMinifyIncompatibleOption) {
85
94
  logError(
86
95
  `Options ${formatOption(noMinifyOption.name)} and ${formatOption(noMinifyIncompatibleOption.name)} are incompatible\n`
@@ -88,9 +97,17 @@ switch (commands[0]) {
88
97
  logHelp()
89
98
  process.exit(1)
90
99
  }
100
+ if (forceQuineCheatsOption && noQuineCheatsOptions) {
101
+ logError(
102
+ `Options ${formatOption(forceQuineCheatsOption.name)} and ${formatOption(noQuineCheatsOptions.name)} are incompatible\n`
103
+ )
104
+ logHelp()
105
+ process.exit(1)
106
+ }
91
107
  noMinifyOption && assertOptionIsBoolean(noMinifyOption)
92
108
  mangleNamesOption && assertOptionIsBoolean(mangleNamesOption)
93
109
  forceQuineCheatsOption && assertOptionIsBoolean(forceQuineCheatsOption)
110
+ noQuineCheatsOptions && assertOptionIsBoolean(noQuineCheatsOptions)
94
111
  if ("golf" == commands[0] || "minify" == commands[0]) {
95
112
  const watchOption = popOption("watch"),
96
113
  target = commands[1]
@@ -135,11 +152,10 @@ switch (commands[0]) {
135
152
  scriptName,
136
153
  filePath: target,
137
154
  mangleNames: mangleNamesOption?.value,
138
- forceQuineCheats: forceQuineCheatsOption?.value
155
+ forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value
139
156
  }),
140
157
  timeTook = performance.now() - timeStart
141
- for (const { message, line } of warnings)
142
- log(`Warning "${chalk.bold(message)}" on line ${chalk.bold(line + "")}`)
158
+ for (const { message } of warnings) log("Warning: " + chalk.bold(message))
143
159
  await writeFilePersistent(outputPath, script)
144
160
  .catch(error => {
145
161
  if (!commands[2] || "EISDIR" != error.code) throw error
@@ -178,16 +194,67 @@ switch (commands[0]) {
178
194
  process.exit(1)
179
195
  }
180
196
  } else scripts.push("*.*")
181
- if ("push" == commands[0]) {
182
- const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } = await pushModule
197
+ const watchOption = popOption("watch")
198
+ if ("push" != commands[0] || watchOption?.value) {
199
+ const dtsPathOption = popOption(
200
+ "dts-path",
201
+ "type-declaration-path",
202
+ "type-declaration",
203
+ "dts",
204
+ "gen-types"
205
+ )
206
+ dtsPathOption &&
207
+ "dts-path" != dtsPathOption.name &&
208
+ "type-declaration-path" != dtsPathOption.name &&
209
+ console.warn(
210
+ colourF(
211
+ `Warning: ${formatOption(dtsPathOption.name)} is deprecated and will be removed in the\n next minor release of HSM\n You should switch to using its alias ${colourN("--dts-path")}\n`
212
+ )
213
+ )
183
214
  complainAboutUnrecognisedOptions()
184
- const infos = await push(sourcePath, hackmudPath, {
215
+ const { watch } = await watchModule
216
+ watch(sourcePath, hackmudPath, {
185
217
  scripts,
186
218
  onPush: info => logInfo(info, hackmudPath),
219
+ typeDeclarationPath: dtsPathOption?.value.toString(),
187
220
  minify: noMinifyOption && !noMinifyOption.value,
188
221
  mangleNames: mangleNamesOption?.value,
189
- forceQuineCheats: forceQuineCheatsOption?.value
222
+ onReady: () => log("Watching"),
223
+ forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value
190
224
  })
225
+ autoExit = !1
226
+ } else {
227
+ const dtsPathOption = popOption("dts-path")
228
+ complainAboutUnrecognisedOptions()
229
+ let declarationPathPromise
230
+ if (dtsPathOption) {
231
+ if ("string" != typeof dtsPathOption.value) {
232
+ logError(
233
+ `Option ${formatOption(dtsPathOption.name)} must be a string, got ${colourV(dtsPathOption.value)}\n`
234
+ )
235
+ logHelp()
236
+ process.exit(1)
237
+ }
238
+ let typeDeclarationPath = resolve(dtsPathOption.value)
239
+ const typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
240
+ declarationPathPromise = writeFile(typeDeclarationPath, typeDeclaration)
241
+ .catch(error => {
242
+ assert(error instanceof Error, "src/bin/hsm.ts:288:38")
243
+ if ("EISDIR" != error.code) throw error
244
+ typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
245
+ return writeFile(typeDeclarationPath, typeDeclaration)
246
+ })
247
+ .then(() => typeDeclarationPath)
248
+ }
249
+ const { push, MissingSourceFolderError, MissingHackmudFolderError, NoUsersError } =
250
+ await pushModule,
251
+ infos = await push(sourcePath, hackmudPath, {
252
+ scripts,
253
+ onPush: info => logInfo(info, hackmudPath),
254
+ minify: noMinifyOption && !noMinifyOption.value,
255
+ mangleNames: mangleNamesOption?.value,
256
+ forceQuineCheats: forceQuineCheatsOption?.value ?? !noQuineCheatsOptions?.value
257
+ })
191
258
  if (infos instanceof Error) {
192
259
  logError(infos.message)
193
260
  if (infos instanceof MissingSourceFolderError || infos instanceof NoUsersError) {
@@ -199,25 +266,8 @@ switch (commands[0]) {
199
266
  `If this is not where your hackmud folder is, you can specify it with the\n${colourN("--hackmud-path")}=${colourB("<path>")} option or ${colourN("HSM_HACKMUD_PATH")} environment variable`
200
267
  )
201
268
  } else infos.length || logError("Could not find any scripts to push")
202
- } else {
203
- const typeDeclarationPathOption = popOption(
204
- "type-declaration-path",
205
- "type-declaration",
206
- "dts",
207
- "gen-types"
208
- )
209
- complainAboutUnrecognisedOptions()
210
- const { watch } = await watchModule
211
- watch(sourcePath, hackmudPath, {
212
- scripts,
213
- onPush: info => logInfo(info, hackmudPath),
214
- typeDeclarationPath: typeDeclarationPathOption?.value.toString(),
215
- minify: noMinifyOption && !noMinifyOption.value,
216
- mangleNames: mangleNamesOption?.value,
217
- onReady: () => log("Watching"),
218
- forceQuineCheats: forceQuineCheatsOption?.value
219
- })
220
- autoExit = !1
269
+ declarationPathPromise &&
270
+ log("Wrote type declaration to " + chalk.bold(await declarationPathPromise))
221
271
  }
222
272
  }
223
273
  }
@@ -251,7 +301,16 @@ switch (commands[0]) {
251
301
  case "gen-type-declaration":
252
302
  case "gen-dts":
253
303
  case "gen-types":
304
+ case "emit-dts":
254
305
  {
306
+ if ("emit-dts" != commands[0] && "gen-dts" != commands[0]) {
307
+ warnedDeprecatedEmitDtsAlias = !0
308
+ console.warn(
309
+ colourF(
310
+ `Warning: ${colourC("hsm")} ${colourL(commands[0])} is deprecated and will be removed\n in the next minor release of HSM\n You should switch to using its alias ${colourC("hsm")} ${colourL("emit-dts")}\n`
311
+ )
312
+ )
313
+ }
255
314
  const hackmudPath = getHackmudPath(),
256
315
  target = commands[1]
257
316
  if (!target) {
@@ -265,7 +324,7 @@ switch (commands[0]) {
265
324
  typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
266
325
  let typeDeclarationPath = resolve(outputPath)
267
326
  await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
268
- assert(error instanceof Error, "src/bin/hsm.ts:343:35")
327
+ assert(error instanceof Error, "src/bin/hsm.ts:422:35")
269
328
  if ("EISDIR" != error.code) throw error
270
329
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
271
330
  return writeFile(typeDeclarationPath, typeDeclaration)
@@ -274,7 +333,6 @@ switch (commands[0]) {
274
333
  }
275
334
  break
276
335
  case "help":
277
- case "h":
278
336
  logHelp()
279
337
  break
280
338
  default:
@@ -284,23 +342,21 @@ switch (commands[0]) {
284
342
  autoExit && process.exit()
285
343
  function logHelp() {
286
344
  const pushCommandDescription = "Push scripts from a directory to hackmud user's scripts directories",
287
- forceQuineCheatsOptionDescription = `Force quine cheats on. Use ${colourN("--force-quine-cheats")}=${colourV("false")} to force off`,
288
345
  hackmudPathOption = `${colourN("--hackmud-path")}=${colourB("<path>")}\n Override hackmud path`
289
- console.log(colourN("Version") + colourS(": ") + colourV("0.20.4-52a588b"))
290
346
  switch (commands[0]) {
291
347
  case "dev":
292
348
  case "watch":
293
349
  case "push":
294
350
  console.log(
295
351
  colourS(
296
- `\n${colourJ("push" == commands[0] ? pushCommandDescription : "Watch a directory and push a script when modified")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB('<directory> ["<script user>.<script name>"...]')}\n\n${colourA("Arguments:")}\n${colourB("<directory>")}\n The source directory containing your scripts\n${colourB("<script user>")}\n A user to push script(s) to. Can be set to wild card (${colourV("*")}) which will try\n and discover users to push to\n${colourB("<script name>")}\n Name of a script to push. Can be set to wild card (${colourV("*")}) to find all scripts\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${hackmudPathOption}\n${"push" == commands[0] ? "" : `${colourN("--type-declaration-path")}=${colourB("<path>")}\n Path to generate a type declaration file for the scripts\n`}\n${colourA("Examples:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")}\n Pushes all scripts found in ${colourV("src")} folder to all users\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")}\n Pushes a script named ${colourL("bar")} found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")} ${colourC("baz")}${colourV(".")}${colourL("qux")}\n Multiple can be specified\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("*")}\n Pushes all scripts found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("foo")}\n Pushes all scripts named ${colourL("foo")} found in ${colourV("src")} folder to all user\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("*")}\n Pushes all scripts found in ${colourV("src")} folder to all users`
352
+ `${colourJ("push" == commands[0] ? pushCommandDescription : "Watch a directory and push a script when modified")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB('<directory> ["<script user>.<script name>"...]')}\n\n${colourA("Arguments:")}\n${colourB("<directory>")}\n The source directory containing your scripts\n${colourB("<script user>")}\n A user to push script(s) to. Can be set to wild card (${colourV("*")}) which will try\n and discover users to push to\n${colourB("<script name>")}\n Name of a script to push. Can be set to wild card (${colourV("*")}) to find all scripts\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}, ${colourN("--no-quine-cheats")}\n Force quine cheats on or off\n${hackmudPathOption}\n${colourN("--dts-path")}=${colourB("<path>")}\n Path to generate a type declaration (.d.ts) file for the scripts\n${colourN("--watch")}\n Watch for changes\n\n${colourA("Examples:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")}\n Pushes all scripts found in ${colourV("src")} folder to all users\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")}\n Pushes a script named ${colourL("bar")} found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("bar")} ${colourC("baz")}${colourV(".")}${colourL("qux")}\n Multiple can be specified\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("foo")}${colourV(".")}${colourL("*")}\n Pushes all scripts found in ${colourV("src")} folder to user ${userColours.get("foo")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("foo")}\n Pushes all scripts named ${colourL("foo")} found in ${colourV("src")} folder to all user\n${colourC("hsm")} ${colourL(commands[0])} ${colourV("src")} ${colourC("*")}${colourV(".")}${colourL("*")}\n Pushes all scripts found in ${colourV("src")} folder to all users`
297
353
  )
298
354
  )
299
355
  break
300
356
  case "pull":
301
357
  console.log(
302
358
  colourS(
303
- `\n${colourJ("Pull a script a from a hackmud user's script directory")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<script user>")}${colourV(".")}${colourB("<script name>")}\n\n${colourA("Options:")}\n${hackmudPathOption}`
359
+ `${colourJ("Pull a script a from a hackmud user's script directory")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<script user>")}${colourV(".")}${colourB("<script name>")}\n\n${colourA("Options:")}\n${hackmudPathOption}`
304
360
  )
305
361
  )
306
362
  break
@@ -308,7 +364,7 @@ function logHelp() {
308
364
  case "golf":
309
365
  console.log(
310
366
  colourS(
311
- `\n${colourJ("Minify a script file on the spot")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<target> [output path]")}\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}\n ${forceQuineCheatsOptionDescription}\n${colourN("--watch")}\n Watch for changes`
367
+ `${colourJ("Minify a script file on the spot")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<target> [output path]")}\n\n${colourA("Options:")}\n${colourN("--no-minify")}\n Skip minification to produce a "readable" script\n${colourN("--mangle-names")}\n Reduce character count further but lose function names in error call stacks\n${colourN("--force-quine-cheats")}, ${colourN("--no-quine-cheats")}\n Force quine cheats on or off\n${colourN("--watch")}\n Watch for changes`
312
368
  )
313
369
  )
314
370
  break
@@ -316,6 +372,15 @@ function logHelp() {
316
372
  case "gen-type-declaration":
317
373
  case "gen-dts":
318
374
  case "gen-types":
375
+ case "emit-dts":
376
+ warnedDeprecatedEmitDtsAlias ||
377
+ "emit-dts" == commands[0] ||
378
+ "gen-dts" == commands[0] ||
379
+ console.warn(
380
+ colourF(
381
+ `Warning: ${colourC("hsm")} ${colourL(commands[0])} is deprecated and will be removed\n in the next minor release of HSM\n You should switch to using its alias ${colourC("hsm")} ${colourL("emit-dts")}\n`
382
+ )
383
+ )
319
384
  console.log(
320
385
  colourS(
321
386
  `${colourJ("Generate a type declaration file for a directory of scripts")}\n\n${colourA("Usage:")}\n${colourC("hsm")} ${colourL(commands[0])} ${colourB("<directory> [output path]")}\n\n${colourA("Options:")}\n${hackmudPathOption}`
@@ -325,25 +390,27 @@ function logHelp() {
325
390
  case "sync-macros":
326
391
  console.log(
327
392
  colourS(
328
- `\n${colourJ("Sync macros across all hackmud users")}\n\n${colourA("Options:")}\n${hackmudPathOption}`
393
+ `${colourJ("Sync macros across all hackmud users")}\n\n${colourA("Options:")}\n${hackmudPathOption}`
329
394
  )
330
395
  )
331
396
  break
332
397
  default:
333
398
  console.log(
334
399
  colourS(
335
- `\n${colourJ("Hackmud Script Manager")}\n\n${colourA("Commands:")}\n${colourL("push")}\n ${pushCommandDescription}\n${colourL("dev")}\n Watch a directory and push a script when modified\n${colourL("golf")}\n Minify a script file on the spot\n${colourL("gen-dts")}\n Generate a type declaration file for a directory of scripts\n${colourL("sync-macros")}\n Sync macros across all hackmud users\n${colourL("pull")}\n Pull a script a from a hackmud user's script directory`
400
+ `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.20.4-66e0e13")}\n\n${colourA("Commands:")}\n${colourL("push")}\n ${pushCommandDescription}\n${colourL("minify")}\n Minify a script file on the spot\n${colourL("emit-dts")}\n Generate a type declaration file for a directory of scripts\n${colourL("sync-macros")}\n Sync macros across all hackmud users\n${colourL("pull")}\n Pull a script a from a hackmud user's script directory\n\n${colourA("Options:")}\n${colourN("--help")}\n Can be used on any command e.g. ${colourC("hsm")} ${colourL("push")} ${colourN("--help")} to show helpful information`
336
401
  )
337
402
  )
338
403
  }
339
404
  }
340
- function logInfo({ path, users, characterCount, error }, hackmudPath) {
405
+ function logInfo({ path, users, characterCount, error, warnings }, hackmudPath) {
341
406
  path = relative(".", path)
342
- error ?
343
- logError(`Error "${chalk.bold(error.message)}" in ${chalk.bold(path)}`)
344
- : log(
407
+ if (error) logError(`Error "${chalk.bold(error.message)}" in ${chalk.bold(path)}`)
408
+ else {
409
+ for (const warning of warnings) console.warn(colourF("Warning: " + warning.message))
410
+ log(
345
411
  `Pushed ${chalk.bold(path)} to ${users.map(user => chalk.bold(userColours.get(user))).join(", ")} | ${chalk.bold(characterCount + "")} chars | ${chalk.bold(resolve(hackmudPath, users[0], "scripts", basename(path, extname(path))) + ".js")}`
346
412
  )
413
+ }
347
414
  }
348
415
  function logError(message) {
349
416
  console.error(colourD(message))
@@ -351,16 +418,28 @@ function logError(message) {
351
418
  }
352
419
  function getHackmudPath() {
353
420
  const hackmudPathOption = popOption("hackmud-path")
354
- if (null != hackmudPathOption && "string" != typeof hackmudPathOption) {
355
- logError(`Option ${colourN("--hackmud-path")} must be a string, got ${colourV(hackmudPathOption)}\n`)
356
- logHelp()
357
- process.exit(1)
421
+ if (hackmudPathOption) {
422
+ if ("string" != typeof hackmudPathOption.value) {
423
+ logError(`Option ${colourN("--hackmud-path")} must be a string, got ${colourV(hackmudPathOption.value)}\n`)
424
+ logHelp()
425
+ process.exit(1)
426
+ }
427
+ if (!hackmudPathOption.value) {
428
+ logError(`Option ${colourN("--hackmud-path")} was specified but empty\n`)
429
+ logHelp()
430
+ process.exit(1)
431
+ }
432
+ return hackmudPathOption.value
358
433
  }
359
- return (
360
- hackmudPathOption ||
361
- process.env.HSM_HACKMUD_PATH ||
362
- ("win32" == process.platform ? resolve(process.env.APPDATA, "hackmud") : resolve(homedir(), ".config/hackmud"))
363
- )
434
+ if (null != process.env.HSM_HACKMUD_PATH) {
435
+ if (!process.env.HSM_HACKMUD_PATH) {
436
+ logError(`Environment variable ${colourN("HSM_HACKMUD_PATH")} was specified but empty\n`)
437
+ logHelp()
438
+ process.exit(1)
439
+ }
440
+ return process.env.HSM_HACKMUD_PATH
441
+ }
442
+ return "win32" == process.platform ? resolve(process.env.APPDATA, "hackmud") : resolve(homedir(), ".config/hackmud")
364
443
  }
365
444
  function assertOptionIsBoolean(option) {
366
445
  if ("boolean" != typeof option.value) {
@@ -372,16 +451,15 @@ function assertOptionIsBoolean(option) {
372
451
  function popOption(...names) {
373
452
  const presentOptionNames = names.filter(name => options.has(name))
374
453
  if (!presentOptionNames.length) return
375
- const presentOptionNamesWithDashDash = presentOptionNames.map(formatOption)
376
454
  if (presentOptionNames.length > 1) {
377
455
  logError(
378
- `The options ${presentOptionNamesWithDashDash.join(", ")} are aliases for each other. Please only specify one`
456
+ `The options ${presentOptionNames.map(formatOption).join(", ")} are aliases for each other. Please only specify one`
379
457
  )
380
458
  process.exit(1)
381
459
  }
382
460
  const value = options.get(presentOptionNames[0])
383
461
  options.delete(presentOptionNames[0])
384
- return { name: presentOptionNamesWithDashDash[0], value }
462
+ return { name: presentOptionNames[0], value }
385
463
  }
386
464
  function complainAboutUnrecognisedOptions() {
387
465
  if (options.size) {