File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -880,6 +880,22 @@ export function validateManifest(manifest: Manifest): Manifest {
880
880
881
881
validateEngineCompatibility ( manifest . engines [ 'vscode' ] ) ;
882
882
883
+ const hasActivationEvents = ! ! manifest . activationEvents ;
884
+ const hasMain = ! ! manifest . main ;
885
+ const hasBrowser = ! ! manifest . browser ;
886
+
887
+ if ( hasActivationEvents ) {
888
+ if ( ! hasMain && ! hasBrowser ) {
889
+ throw new Error (
890
+ "Manifest needs either a 'main' or 'browser' property, given it has a 'activationEvents' property."
891
+ ) ;
892
+ }
893
+ } else if ( hasMain ) {
894
+ throw new Error ( "Manifest needs the 'activationEvents' property, given it has a 'main' property." ) ;
895
+ } else if ( hasBrowser ) {
896
+ throw new Error ( "Manifest needs the 'activationEvents' property, given it has a 'browser' property." ) ;
897
+ }
898
+
883
899
if ( manifest . devDependencies && manifest . devDependencies [ '@types/vscode' ] ) {
884
900
validateVSCodeTypesCompatibility ( manifest . engines [ 'vscode' ] , manifest . devDependencies [ '@types/vscode' ] ) ;
885
901
}
Original file line number Diff line number Diff line change @@ -377,6 +377,16 @@ describe('validateManifest', () => {
377
377
) ;
378
378
} ) ;
379
379
} ) ;
380
+
381
+ it ( 'should validate activationEvents against main and browser' , ( ) => {
382
+ assert . throws ( ( ) => validateManifest ( createManifest ( { activationEvents : [ 'any' ] } ) ) ) ;
383
+ assert . throws ( ( ) => validateManifest ( createManifest ( { main : 'main.js' } ) ) ) ;
384
+ assert . throws ( ( ) => validateManifest ( createManifest ( { browser : 'browser.js' } ) ) ) ;
385
+ assert . throws ( ( ) => validateManifest ( createManifest ( { main : 'main.js' , browser : 'browser.js' } ) ) ) ;
386
+ validateManifest ( createManifest ( { activationEvents : [ 'any' ] , main : 'main.js' } ) ) ;
387
+ validateManifest ( createManifest ( { activationEvents : [ 'any' ] , browser : 'browser.js' } ) ) ;
388
+ validateManifest ( createManifest ( { activationEvents : [ 'any' ] , main : 'main.js' , browser : 'browser.js' } ) ) ;
389
+ } ) ;
380
390
} ) ;
381
391
382
392
describe ( 'toVsixManifest' , ( ) => {
You can’t perform that action at this time.
0 commit comments