Skip to content

Commit

Permalink
Merge pull request #668 from microsoft/TylerLeonhardt/only-enforce-ma…
Browse files Browse the repository at this point in the history
…jor-minor

fix: only enforce major and minor version of types check
  • Loading branch information
TylerLeonhardt authored Dec 16, 2021
2 parents f710e83 + 63c89ae commit 12586ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/test/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('validateVSCodeTypesCompatibility', () => {
validateVSCodeTypesCompatibility('1.30.0', '1.30.0');
validateVSCodeTypesCompatibility('1.30.0', '1.20.0');
validateVSCodeTypesCompatibility('1.46.0', '1.45.1');
validateVSCodeTypesCompatibility('1.45.0', '1.45.1');

assert.throws(() => validateVSCodeTypesCompatibility('1.30.0', '1.40.0'));
assert.throws(() => validateVSCodeTypesCompatibility('1.30.0', '^1.40.0'));
Expand Down
10 changes: 5 additions & 5 deletions src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export function validateEngineCompatibility(version: string): void {

/**
* User shouldn't use a newer version of @types/vscode than the one specified in engines.vscode
*
* NOTE: This is enforced at the major and minor level. Since we don't have control over the patch
* version (it's auto-incremented by DefinitelyTyped), we don't look at the patch version at all.
*/
export function validateVSCodeTypesCompatibility(engineVersion: string, typeVersion: string): void {
if (engineVersion === '*') {
Expand Down Expand Up @@ -78,14 +81,14 @@ export function validateVSCodeTypesCompatibility(engineVersion: string, typeVers
// For all `x`, use smallest version for comparison
plainEngineVersion = plainEngineVersion.replace(/x/g, '0');

const [typeMajor, typeMinor, typePatch] = plainTypeVersion.split('.').map(x => {
const [typeMajor, typeMinor] = plainTypeVersion.split('.').map(x => {
try {
return parseInt(x);
} catch (err) {
return 0;
}
});
const [engineMajor, engineMinor, enginePatch] = plainEngineVersion.split('.').map(x => {
const [engineMajor, engineMinor] = plainEngineVersion.split('.').map(x => {
try {
return parseInt(x);
} catch (err) {
Expand All @@ -103,7 +106,4 @@ export function validateVSCodeTypesCompatibility(engineVersion: string, typeVers
if (typeMajor === engineMajor && typeMinor > engineMinor) {
throw error;
}
if (typeMajor === engineMajor && typeMinor === engineMinor && typePatch > enginePatch) {
throw error;
}
}

0 comments on commit 12586ed

Please sign in to comment.