jsbeeb 1.13.0 → 1.13.1

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/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "name": "jsbeeb",
8
8
  "description": "Emulate a BBC Micro",
9
9
  "repository": "git@github.com:mattgodbolt/jsbeeb.git",
10
- "version": "1.13.0",
10
+ "version": "1.13.1",
11
11
  "//": "If you change the version of Node, it must also be updated at the top of the Dockerfile.",
12
12
  "engines": {
13
13
  "node": ">=22.12.0"
package/src/app/app.js CHANGED
@@ -5,6 +5,8 @@ import * as fs from "fs";
5
5
  import * as path from "path";
6
6
  import { ArgumentParser } from "argparse";
7
7
 
8
+ import { getArguments } from "./args.js";
9
+
8
10
  const store = new Store();
9
11
 
10
12
  ipcMain.on("set-title", (event, title) => {
@@ -20,21 +22,6 @@ ipcMain.on("save-settings", (event, settings) => {
20
22
 
21
23
  const isMac = process.platform === "darwin";
22
24
 
23
- function getArguments() {
24
- // Heinous hack to get "built" versions working
25
- let args;
26
- if (path.basename(process.argv[0]) === "jsbeeb")
27
- // Is this ia "built" version?
28
- args = process.argv.slice(1);
29
- else args = process.argv.slice(2);
30
-
31
- // Filter out Chrome switches that appear in process.argv. The snap wrapper
32
- // adds --no-sandbox for compatibility, and `--disable-gpu` might be useful.
33
- // Note that we don't support snap any more, but these seemed useful to leave.
34
- const ignoredChromeFlags = ["--no-sandbox", "--disable-gpu"];
35
- return args.filter((arg) => !ignoredChromeFlags.includes(arg));
36
- }
37
-
38
25
  const parser = new ArgumentParser({
39
26
  prog: "jsbeeb",
40
27
  add_help: true,
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Returns the command-line arguments the user actually passed to jsbeeb, with
5
+ * the Electron binary path(s) and known runtime-injected flags stripped.
6
+ *
7
+ * @param {string[]} [argv=process.argv] Full argv array.
8
+ * @param {boolean} [defaultApp=process.defaultApp]
9
+ * True when running under `electron .` (dev). Electron only sets
10
+ * process.defaultApp in that case, so we use it instead of comparing
11
+ * basename(argv[0]) === "jsbeeb" (the previous check), which failed on
12
+ * Windows where the binary is jsbeeb.exe, silently dropping the first
13
+ * user argument. See issue #684.
14
+ * @returns {string[]}
15
+ */
16
+ export function getArguments(argv = process.argv, defaultApp = process.defaultApp) {
17
+ // In a packaged Electron app argv is [appBinary, ...userArgs]; when running
18
+ // under `electron .` (dev) it is [electronBinary, appPath, ...userArgs].
19
+ const args = defaultApp ? argv.slice(2) : argv.slice(1);
20
+
21
+ // Filter out Chrome switches that appear in argv. The snap wrapper adds
22
+ // --no-sandbox for compatibility, and --disable-gpu might be useful. We
23
+ // don't support snap any more, but these seemed useful to leave.
24
+ const ignoredChromeFlags = ["--no-sandbox", "--disable-gpu"];
25
+ return args.filter((arg) => !ignoredChromeFlags.includes(arg));
26
+ }