@@ -6,7 +6,11 @@ import { ThirdPartyExtractor } from './ThirdPartyExtractor';
6
6
describe ( 'ThirdPartyExtractor' , ( ) => {
7
7
const projectRoot = join ( __dirname , '..' , '..' , '..' ) ;
8
8
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
+ } ) ;
10
14
11
15
it ( 'should correctly infer pkg dir with types field in package.json' , ( ) => {
12
16
const tsupDir = thirdPartyExtractor . inferPkgDir ( 'tsup' ) ;
@@ -52,4 +56,14 @@ describe('ThirdPartyExtractor', () => {
52
56
expect ( fs . existsSync ( join ( destDir , 'tsup' ) ) ) . toEqual ( true ) ;
53
57
expect ( fs . existsSync ( join ( destDir , '@types/react' ) ) ) . toEqual ( true ) ;
54
58
} ) ;
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
+ } ) ;
55
69
} ) ;
0 commit comments