@@ -1663,9 +1663,7 @@ test.serial('downlevels JS imported by TS when allowJs is true', async (t) => {
16631663
16641664test . serial ( 'excludes user-configured outDir from processing when allowJs is true' , async ( t ) => {
16651665 const outDir = path . join ( __dirname , 'fixtures/allow-js-from-ts/.out' ) ;
1666- if ( fs . existsSync ( outDir ) ) {
1667- fs . rmSync ( outDir , { recursive : true , force : true } ) ;
1668- }
1666+ fs . rmSync ( outDir , { recursive : true , force : true } ) ;
16691667
16701668 const bundle = await rollup ( {
16711669 input : 'fixtures/allow-js-from-ts/src/main.ts' ,
@@ -1678,12 +1676,20 @@ test.serial('excludes user-configured outDir from processing when allowJs is tru
16781676 onwarn
16791677 } ) ;
16801678
1681- // Ensure Rollup did not pull any files from the outDir into the graph
1682- const normalizedOutDir = path . normalize ( outDir + path . sep ) ;
1683- t . true ( bundle . watchFiles . every ( ( f ) => ! path . normalize ( f ) . startsWith ( normalizedOutDir ) ) ) ;
1684-
1685- // Cleanup
1686- if ( fs . existsSync ( outDir ) ) {
1679+ try {
1680+ // Ensure Rollup did not pull any files from the outDir into the graph
1681+ const normalizeForCompare = ( p ) => {
1682+ const r = path . resolve ( p ) ;
1683+ return process . platform === 'win32' ? r . toLowerCase ( ) : r ;
1684+ } ;
1685+ const outDirAbs = normalizeForCompare ( outDir ) ;
1686+ const isInside = ( parent , child ) => {
1687+ const rel = path . relative ( parent , normalizeForCompare ( child ) ) ;
1688+ return rel && ! rel . startsWith ( '..' ) && ! path . isAbsolute ( rel ) ;
1689+ } ;
1690+ t . true ( bundle . watchFiles . every ( ( f ) => ! isInside ( outDirAbs , f ) ) ) ;
1691+ } finally {
1692+ await bundle . close ( ) ;
16871693 fs . rmSync ( outDir , { recursive : true , force : true } ) ;
16881694 }
16891695} ) ;
0 commit comments