Skip to content

Commit 0657be9

Browse files
list templates
1 parent f6a67eb commit 0657be9

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

.github/workflows/unity-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
- name: create unity project
6060
shell: bash
6161
run: |
62+
unity-cli list-templates --unity-editor "${UNITY_EDITOR_PATH}" --json
6263
unity-cli create-project --name "Unity Project" --unity-editor "${UNITY_EDITOR_PATH}" --json
6364
- name: verify UNITY_PROJECT_PATH variable
6465
shell: bash

src/cli.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,12 @@ program.command('hub-version')
117117
.description('Print the version of the Unity Hub.')
118118
.action(async () => {
119119
const unityHub = new UnityHub();
120-
const version = await unityHub.Version();
121-
process.stdout.write(`${version}\n`);
120+
try {
121+
const version = await unityHub.Version();
122+
process.stdout.write(`${version}\n`);
123+
} catch (error) {
124+
process.stdout.write(`${error}\n`);
125+
}
122126
});
123127

124128
program.command('hub-install')

src/unity-hub.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,12 @@ chmod -R 777 "$hubPath"`]);
432432
}
433433
}
434434

435-
await fs.promises.access(asarPath, fs.constants.R_OK);
435+
try {
436+
await fs.promises.access(asarPath, fs.constants.R_OK);
437+
} catch {
438+
throw new Error('Unity Hub is not installed.');
439+
}
440+
436441
const fileBuffer = asar.extractFile(asarPath, 'package.json');
437442
const packageJson = JSON.parse(fileBuffer.toString());
438443
const version = coerce(packageJson.version);

tests/unity-hub.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { UnityHub } from '../src/unity-hub';
33
jest.setTimeout(30000); // UnityHub operations can be slow
44

55
describe('UnityHub', () => {
6+
it('should get the Unity Hub version', async () => {
7+
const unityHub = new UnityHub();
8+
const version = await unityHub.Version();
9+
expect(version).toBeDefined();
10+
expect(typeof version).toBe('string');
11+
});
12+
613
it('should list installed editors', async () => {
714
const unityHub = new UnityHub();
815
const editors = await unityHub.ListInstalledEditors();

0 commit comments

Comments
 (0)