Skip to content

Commit

Permalink
add executes code property (#1024)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 authored Jul 18, 2024
1 parent dd70844 commit 2e3e3bc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export interface VSIX {
preRelease: boolean;
sponsorLink: string;
pricing: string;
executesCode:boolean;
}

export class BaseProcessor implements IProcessor {
Expand Down Expand Up @@ -547,6 +548,7 @@ export class ManifestProcessor extends BaseProcessor {
: '',
enabledApiProposals: manifest.enabledApiProposals ? manifest.enabledApiProposals.join(',') : '',
preRelease: !!this.options.preRelease,
executesCode: !!(manifest.main ?? manifest.browser),
sponsorLink: manifest.sponsor?.url || '',
};

Expand Down Expand Up @@ -1482,6 +1484,7 @@ export async function toVsixManifest(vsix: VSIX): Promise<string> {
<Property Id="Microsoft.VisualStudio.Code.LocalizedLanguages" Value="${escape(vsix.localizedLanguages)}" />
<Property Id="Microsoft.VisualStudio.Code.EnabledApiProposals" Value="${escape(vsix.enabledApiProposals)}" />
${vsix.preRelease ? `<Property Id="Microsoft.VisualStudio.Code.PreRelease" Value="${escape(vsix.preRelease)}" />` : ''}
${vsix.executesCode ? `<Property Id="Microsoft.VisualStudio.Code.ExecutesCode" Value="${escape(vsix.executesCode)}" />` : ''}
${vsix.sponsorLink
? `<Property Id="Microsoft.VisualStudio.Code.SponsorLink" Value="${escape(vsix.sponsorLink)}" />`
: ''
Expand Down
29 changes: 29 additions & 0 deletions src/test/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,35 @@ describe('toVsixManifest', () => {
assertProperty(xmlManifest, 'Microsoft.VisualStudio.Code.PreRelease', 'true');
});

it('should add executes code property when main is passed', async () => {
const manifest = createManifest({ main: 'main.js' });
const files = [{ path: 'extension/main.js', contents: Buffer.from('') }];

const raw = await _toVsixManifest(manifest, files);
const xmlManifest = await parseXmlManifest(raw);

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

it('should add executes code property when browser is passed', async () => {
const manifest = createManifest({ browser: 'browser.js' });
const files = [{ path: 'extension/browser.js', contents: Buffer.from('') }];

const raw = await _toVsixManifest(manifest, files);
const xmlManifest = await parseXmlManifest(raw);

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

it('should not add executes code property when neither main nor browser is passed', async () => {
const manifest = createManifest();

const raw = await _toVsixManifest(manifest, []);
const xmlManifest = await parseXmlManifest(raw);

assertMissingProperty(xmlManifest, 'Microsoft.VisualStudio.Code.ExecutesCode');
});

it('should add sponsor link property', () => {
const sponsor = { url: 'https://foo.bar' };
const manifest: Manifest = {
Expand Down

0 comments on commit 2e3e3bc

Please sign in to comment.