Skip to content

Commit 774e3ca

Browse files
unity-cli@v1.0.4 (#5)
- added hub-install `--auto-update` arg
1 parent 910a11f commit 774e3ca

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

.github/workflows/unity-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
npm run build
3535
npm run link
3636
unity-cli --version
37-
unity-cli hub-install
37+
unity-cli hub-install --auto-update
3838
unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
3939
setup_output=$(unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-targets }}" --json)
4040
unity_editor_path=$(echo "$setup_output" | tail -n 1 | jq -r '.UNITY_EDITOR')

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rage-against-the-pixel/unity-cli",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A command line utility for the Unity Game Engine.",
55
"author": "RageAgainstThePixel",
66
"license": "MIT",

src/cli.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ program.command('hub-version')
112112
program.command('hub-install')
113113
.description('Install the Unity Hub.')
114114
.option('--verbose', 'Enable verbose logging.')
115+
.option('--auto-update', 'Automatically updates the Unity Hub if it is already installed.')
115116
.option('--json', 'Prints the last line of output as JSON string.')
116117
.action(async (options) => {
117118
if (options.verbose) {
118119
Logger.instance.logLevel = LogLevel.DEBUG;
119120
}
120121

122+
Logger.instance.debug(JSON.stringify(options));
123+
121124
const unityHub = new UnityHub();
122-
const hubPath = await unityHub.Install();
125+
const hubPath = await unityHub.Install(options.autoUpdate === true);
123126

124127
if (options.json) {
125128
process.stdout.write(`\n${JSON.stringify({ UNITY_HUB_PATH: hubPath })}\n`);

src/unity-hub.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ export class UnityHub {
163163
/**
164164
* Installs or updates the Unity Hub.
165165
* If the Unity Hub is already installed, it will be updated to the latest version.
166+
* @param autoUpdate If true, automatically updates the Unity Hub if it is already installed. Default is true.
166167
* @returns The path to the Unity Hub executable.
167168
*/
168-
public async Install(): Promise<string> {
169+
public async Install(autoUpdate: boolean = true): Promise<string> {
169170
let isInstalled = false;
170171
try {
171172
await fs.promises.access(this.executable, fs.constants.X_OK);
@@ -174,7 +175,7 @@ export class UnityHub {
174175
await this.installHub();
175176
}
176177

177-
if (isInstalled) {
178+
if (isInstalled && autoUpdate) {
178179
const installedVersion: SemVer = await this.getInstalledHubVersion();
179180
this.logger.ci(`Installed Unity Hub version: ${installedVersion.version}`);
180181
let latestVersion: SemVer | undefined = undefined;

0 commit comments

Comments
 (0)