Support new unity versioning scheme with regex matching groups
parent
35b5a08132
commit
056d560f58
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -11,6 +11,12 @@ describe('UnityVersionParser', () => {
|
|||
m_EditorVersionWithRevision: 2022.3.7f1 (b16b3b16c7a0)`;
|
||||
expect(UnityVersionParser.parse(projectVersionContents)).toBe('2022.3.7f1');
|
||||
});
|
||||
|
||||
it('parses Unity 6000 and newer from ProjectVersion.txt', () => {
|
||||
const projectVersionContents = `m_EditorVersion: 6000.0.0f1
|
||||
m_EditorVersionWithRevision: 6000.0.0f1 (cb45f9cae8b7)`;
|
||||
expect(UnityVersionParser.parse(projectVersionContents)).toBe('6000.0.0f1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('read', () => {
|
||||
|
|
|
@ -2,16 +2,15 @@ import fs from 'fs';
|
|||
import path from 'path';
|
||||
|
||||
const UnityVersionParser = {
|
||||
get versionPattern() {
|
||||
return /20\d{2}\.\d\.\w{3,4}|3/;
|
||||
},
|
||||
|
||||
parse(projectVersionTxt) {
|
||||
const matches = projectVersionTxt.match(UnityVersionParser.versionPattern);
|
||||
if (!matches || matches.length === 0) {
|
||||
throw new Error(`Failed to parse version from "${projectVersionTxt}".`);
|
||||
const versionRegex = /m_EditorVersion: (\d+\.\d+\.\d+[A-Za-z]?\d+)/;
|
||||
const matches = projectVersionTxt.match(versionRegex);
|
||||
|
||||
if (!matches || matches.length < 2) {
|
||||
throw new Error(`Failed to extract version from "${projectVersionTxt}".`);
|
||||
}
|
||||
return matches[0];
|
||||
|
||||
return matches[1];
|
||||
},
|
||||
|
||||
read(projectPath) {
|
||||
|
|
Loading…
Reference in New Issue