launch-unity 0.8.0 → 0.9.0

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.
Files changed (2) hide show
  1. package/dist/launch.js +14 -1
  2. package/package.json +1 -1
package/dist/launch.js CHANGED
@@ -6,7 +6,8 @@
6
6
  import { execFile, spawn } from "node:child_process";
7
7
  import { existsSync, readFileSync, readdirSync, lstatSync, realpathSync } from "node:fs";
8
8
  import { rm } from "node:fs/promises";
9
- import { join, resolve } from "node:path";
9
+ import { dirname, join, resolve } from "node:path";
10
+ import { fileURLToPath } from "node:url";
10
11
  import { promisify } from "node:util";
11
12
  import { ensureProjectEntryAndUpdate, updateLastModifiedIfExists } from "./unityHub.js";
12
13
  const execFileAsync = promisify(execFile);
@@ -34,6 +35,10 @@ function parseArgs(argv) {
34
35
  printHelp();
35
36
  process.exit(0);
36
37
  }
38
+ if (arg === "--version" || arg === "-v") {
39
+ console.log(getVersion());
40
+ process.exit(0);
41
+ }
37
42
  if (arg === "-r" || arg === "--restart") {
38
43
  restart = true;
39
44
  continue;
@@ -106,6 +111,13 @@ function parseArgs(argv) {
106
111
  }
107
112
  return options;
108
113
  }
114
+ function getVersion() {
115
+ const currentFilePath = fileURLToPath(import.meta.url);
116
+ const currentDir = dirname(currentFilePath);
117
+ const packageJsonPath = join(currentDir, "..", "package.json");
118
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
119
+ return packageJson.version;
120
+ }
109
121
  function printHelp() {
110
122
  const help = `
111
123
  Usage: launch-unity [PROJECT_PATH] [PLATFORM] -- [UNITY_ARGS...]
@@ -122,6 +134,7 @@ Forwarding:
122
134
 
123
135
  Flags:
124
136
  -h, --help Show this help message
137
+ -v, --version Show version number
125
138
  -r, --restart Kill running Unity and restart
126
139
  --max-depth <N> Search depth when PROJECT_PATH is omitted (default 3, -1 unlimited)
127
140
  -u, -a, --unity-hub-entry, --add-unity-hub
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "launch-unity",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Open a Unity project with the matching Editor version (macOS/Windows)",
5
5
  "type": "module",
6
6
  "main": "dist/launch.js",