Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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