Skip to content

Commit

Permalink
fix: include prerelease flag for engine while checking
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jan 31, 2022
1 parent 68ba188 commit bca9e56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class ManifestProcessor extends BaseProcessor {
}

if (target) {
if (engineVersion !== 'latest' && !semver.satisfies(engineVersion, '>=1.61')) {
if (engineVersion !== 'latest' && !semver.satisfies(engineVersion, '>=1.61', { includePrerelease: true })) {
throw new Error(
`Platform specific extension is supported by VS Code >=1.61. Current 'engines.vscode' is '${manifest.engines['vscode']}'.`
);
Expand All @@ -412,7 +412,7 @@ export class ManifestProcessor extends BaseProcessor {
}

if (preRelease) {
if (engineVersion !== 'latest' && !semver.satisfies(engineVersion, '>=1.63')) {
if (engineVersion !== 'latest' && !semver.satisfies(engineVersion, '>=1.63', { includePrerelease: true })) {
throw new Error(
`Pre-release versions are supported by VS Code >=1.63. Current 'engines.vscode' is '${manifest.engines['vscode']}'.`
);
Expand Down
20 changes: 20 additions & 0 deletions src/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,17 @@ describe('toVsixManifest', () => {
assert.strictEqual(dom.PackageManifest.Metadata[0].Identity[0].$.TargetPlatform, 'win32-x64');
});

it('should set the target platform when engine is set to insider', async () => {
const manifest = createManifest({ engines: { vscode: '>=1.62.0-insider' } });
const raw = await _toVsixManifest(manifest, [], { target: 'win32-x64' });
const dom = await parseXmlManifest(raw);

assert.strictEqual(dom.PackageManifest.Metadata[0].Identity[0].$.Id, 'test');
assert.strictEqual(dom.PackageManifest.Metadata[0].Identity[0].$.Version, '0.0.1');
assert.strictEqual(dom.PackageManifest.Metadata[0].Identity[0].$.Publisher, 'mocha');
assert.strictEqual(dom.PackageManifest.Metadata[0].Identity[0].$.TargetPlatform, 'win32-x64');
});

it('should fail when target is invalid', async () => {
const manifest = createManifest();

Expand Down Expand Up @@ -1649,6 +1660,15 @@ describe('toVsixManifest', () => {
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true');
});

it('should add prerelease property when --pre-release flag is passed when engine property is for insiders', async () => {
const manifest = createManifest({ engines: { vscode: '>=1.64.0-insider' } });

const raw = await _toVsixManifest(manifest, [], { preRelease: true });
const xmlManifest = await parseXmlManifest(raw);

assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true');
});

it('should not add prerelease property when --pre-release flag is not passed', async () => {
const manifest = createManifest({ engines: { vscode: '>=1.64.0' } });

Expand Down

0 comments on commit bca9e56

Please sign in to comment.