Skip to content

Commit b8c45ef

Browse files
authored
Merge b2b7551 into fc0a52b
2 parents fc0a52b + b2b7551 commit b8c45ef

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/model/unity-versioning.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ describe('Unity Versioning', () => {
1111
m_EditorVersionWithRevision: 2021.3.4f1 (cb45f9cae8b7)`;
1212
expect(UnityVersioning.parse(projectVersionContents)).toBe('2021.3.4f1');
1313
});
14+
15+
it('parses Unity 6000 and newer from ProjectVersion.txt', () => {
16+
const projectVersionContents = `m_EditorVersion: 6000.0.0f1
17+
m_EditorVersionWithRevision: 6000.0.0f1 (cb45f9cae8b7)`;
18+
expect(UnityVersioning.parse(projectVersionContents)).toBe('6000.0.0f1');
19+
});
1420
});
1521

1622
describe('read', () => {

src/model/unity-versioning.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import fs from 'node:fs';
22
import path from 'node:path';
33

44
export default class UnityVersioning {
5-
static get versionPattern() {
6-
return /20\d{2}\.\d\.\w{3,4}|3/;
7-
}
8-
95
static determineUnityVersion(projectPath: string, unityVersion: string) {
106
if (unityVersion === 'auto') {
117
return UnityVersioning.read(projectPath);
@@ -24,11 +20,13 @@ export default class UnityVersioning {
2420
}
2521

2622
static parse(projectVersionTxt: string) {
27-
const matches = projectVersionTxt.match(UnityVersioning.versionPattern);
28-
if (!matches || matches.length === 0) {
29-
throw new Error(`Failed to parse version from "${projectVersionTxt}".`);
23+
const versionRegex = /m_EditorVersion: (\d+\.\d+\.\d+[A-Za-z]?\d+)/;
24+
const matches = projectVersionTxt.match(versionRegex);
25+
26+
if (!matches || matches.length < 2) {
27+
throw new Error(`Failed to extract version from "${projectVersionTxt}".`);
3028
}
3129

32-
return matches[0];
30+
return matches[1];
3331
}
3432
}

0 commit comments

Comments
 (0)