@@ -6,7 +6,11 @@ import { ThirdPartyExtractor } from './ThirdPartyExtractor';
66describe ( 'ThirdPartyExtractor' , ( ) => {
77 const projectRoot = join ( __dirname , '..' , '..' , '..' ) ;
88 const destDir = join ( projectRoot , 'dist' , 'third-party-extractor' ) ;
9- const thirdPartyExtractor = new ThirdPartyExtractor ( destDir , projectRoot ) ;
9+ const thirdPartyExtractor = new ThirdPartyExtractor ( {
10+ destDir,
11+ context : projectRoot ,
12+ exclude : [ 'ignore-pkg' , / i g n o r e - p k g 2 - / , / i g n o r e - p k g 3 / . toString ( ) ] ,
13+ } ) ;
1014
1115 it ( 'should correctly infer pkg dir with types field in package.json' , ( ) => {
1216 const tsupDir = thirdPartyExtractor . inferPkgDir ( 'tsup' ) ;
@@ -52,4 +56,14 @@ describe('ThirdPartyExtractor', () => {
5256 expect ( fs . existsSync ( join ( destDir , 'tsup' ) ) ) . toEqual ( true ) ;
5357 expect ( fs . existsSync ( join ( destDir , '@types/react' ) ) ) . toEqual ( true ) ;
5458 } ) ;
59+
60+ it ( 'exclude pkg' , async ( ) => {
61+ const excludePkg = [ 'ignore-pkg' , 'ignore-pkg2-subpath' , 'ignore-pkg3' ] ;
62+ excludePkg . forEach ( ( pkg ) => {
63+ thirdPartyExtractor . addPkgs ( pkg , `${ pkg } -dir` ) ;
64+ } ) ;
65+ expect (
66+ Object . keys ( thirdPartyExtractor . pkgs ) . some ( ( p ) => excludePkg . includes ( p ) ) ,
67+ ) . toEqual ( false ) ;
68+ } ) ;
5569} ) ;
0 commit comments