Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unity-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
npm run build
npm run link
unity-cli --version
unity-cli hub-install
unity-cli hub-install --auto-update
unity-cli activate-license --license personal --email "${{ secrets.UNITY_USERNAME }}" --password "${{ secrets.UNITY_PASSWORD }}"
setup_output=$(unity-cli setup-unity --unity-version "${{ matrix.unity-version }}" --build-targets "${{ matrix.build-targets }}" --json)
unity_editor_path=$(echo "$setup_output" | tail -n 1 | jq -r '.UNITY_EDITOR')
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rage-against-the-pixel/unity-cli",
"version": "1.0.3",
"version": "1.0.4",
"description": "A command line utility for the Unity Game Engine.",
"author": "RageAgainstThePixel",
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ program.command('hub-version')
program.command('hub-install')
.description('Install the Unity Hub.')
.option('--verbose', 'Enable verbose logging.')
.option('--auto-update', 'Automatically updates the Unity Hub if it is already installed.')
.option('--json', 'Prints the last line of output as JSON string.')
.action(async (options) => {
if (options.verbose) {
Logger.instance.logLevel = LogLevel.DEBUG;
}

Logger.instance.debug(JSON.stringify(options));

const unityHub = new UnityHub();
const hubPath = await unityHub.Install();
const hubPath = await unityHub.Install(options.autoUpdate === true);

if (options.json) {
process.stdout.write(`\n${JSON.stringify({ UNITY_HUB_PATH: hubPath })}\n`);
Expand Down
5 changes: 3 additions & 2 deletions src/unity-hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ export class UnityHub {
/**
* Installs or updates the Unity Hub.
* If the Unity Hub is already installed, it will be updated to the latest version.
* @param autoUpdate If true, automatically updates the Unity Hub if it is already installed. Default is true.
* @returns The path to the Unity Hub executable.
*/
public async Install(): Promise<string> {
public async Install(autoUpdate: boolean = true): Promise<string> {
let isInstalled = false;
try {
await fs.promises.access(this.executable, fs.constants.X_OK);
Expand All @@ -174,7 +175,7 @@ export class UnityHub {
await this.installHub();
}

if (isInstalled) {
if (isInstalled && autoUpdate) {
const installedVersion: SemVer = await this.getInstalledHubVersion();
this.logger.ci(`Installed Unity Hub version: ${installedVersion.version}`);
let latestVersion: SemVer | undefined = undefined;
Expand Down