@@ -19,12 +19,16 @@ describe('npmPluginLoader', () => {
1919 } )
2020
2121 describe ( 'installNpmPackage' , ( ) => {
22- it ( 'installs with --no-save and --ignore-scripts' , ( ) => {
22+ it ( 'installs with --no-save, --no-package-lock and --ignore-scripts' , ( ) => {
2323 const execSpy = vi . spyOn ( childProcess , 'execFileSync' ) . mockImplementation ( ( ) => Buffer . from ( '' ) )
2424 npmPluginLoader . installNpmPackage ( 'some-pkg@1.0.0' )
25- expect ( execSpy ) . toHaveBeenCalledWith ( 'npm' , [ 'install' , 'some-pkg@1.0.0' , '--no-save' , '--ignore-scripts' ] , {
26- stdio : 'inherit' ,
27- } )
25+ expect ( execSpy ) . toHaveBeenCalledWith (
26+ 'npm' ,
27+ [ 'install' , 'some-pkg@1.0.0' , '--no-save' , '--no-package-lock' , '--ignore-scripts' ] ,
28+ {
29+ stdio : 'inherit' ,
30+ } ,
31+ )
2832 } )
2933 } )
3034
@@ -34,7 +38,7 @@ describe('npmPluginLoader', () => {
3438 await npmPluginLoader . loadPluginViaNpm ( { name : 'p' , package : 'nonexistent-pkg-xyz' , version : '2.3.4' } )
3539 expect ( execSpy ) . toHaveBeenCalledWith (
3640 'npm' ,
37- [ 'install' , 'nonexistent-pkg-xyz@2.3.4' , '--no-save' , '--ignore-scripts' ] ,
41+ [ 'install' , 'nonexistent-pkg-xyz@2.3.4' , '--no-save' , '--no-package-lock' , '-- ignore-scripts'] ,
3842 { stdio : 'inherit' } ,
3943 )
4044 } )
@@ -79,6 +83,14 @@ describe('loadNpmPlugins', () => {
7983 expect ( pluginManager . getPlugins ( ) . length ) . toBe ( 0 )
8084 } )
8185
86+ it ( 'skips an NPM plugin whose exported name does not match the requested name' , async ( ) => {
87+ vi . spyOn ( npmPluginLoader , 'loadPluginViaNpm' ) . mockResolvedValue ( { name : 'actual-name' , default : vi . fn ( ) } )
88+ const warnSpy = vi . spyOn ( core , 'warning' ) . mockImplementation ( ( ) => { } )
89+ await pluginManager . loadNpmPlugins ( [ { name : 'requested-name' , package : ALLOWED } ] )
90+ expect ( warnSpy ) . toHaveBeenCalled ( )
91+ expect ( pluginManager . getPlugins ( ) . length ) . toBe ( 0 )
92+ } )
93+
8294 it ( 'skips an NPM plugin whose name collides with an already-loaded plugin' , async ( ) => {
8395 pluginManager . getPlugins ( ) . push ( { name : 'dup' , default : vi . fn ( ) } )
8496 vi . spyOn ( npmPluginLoader , 'loadPluginViaNpm' ) . mockResolvedValue ( { name : 'dup' , default : vi . fn ( ) } )
0 commit comments