11import { readFileSync } from 'fs-extra' ;
22import ignore from 'ignore' ;
3- import { join } from 'path/posix' ;
43import { readFileIfExisting } from './fileutils' ;
4+ import { joinPathFragments } from './path' ;
55import { workspaceRoot } from './workspace-root' ;
66
77/**
@@ -18,19 +18,23 @@ export function getIgnoredGlobs(
1818 if ( prependRoot ) {
1919 return [
2020 ...getAlwaysIgnore ( root ) ,
21- ...files . flatMap ( ( f ) => getIgnoredGlobsFromFile ( join ( root , f ) , root ) ) ,
21+ ...files . flatMap ( ( f ) =>
22+ getIgnoredGlobsFromFile ( joinPathFragments ( root , f ) , root )
23+ ) ,
2224 ] ;
2325 } else {
2426 return [
2527 ...getAlwaysIgnore ( ) ,
26- ...files . flatMap ( ( f ) => getIgnoredGlobsFromFile ( join ( root , f ) ) ) ,
28+ ...files . flatMap ( ( f ) =>
29+ getIgnoredGlobsFromFile ( joinPathFragments ( root , f ) )
30+ ) ,
2731 ] ;
2832 }
2933}
3034
3135export function getAlwaysIgnore ( root ?: string ) {
3236 const paths = [ 'node_modules' , '**/node_modules' , '.git' ] ;
33- return root ? paths . map ( ( x ) => join ( root , x ) ) : paths ;
37+ return root ? paths . map ( ( x ) => joinPathFragments ( root , x ) ) : paths ;
3438}
3539
3640export function getIgnoreObject ( root : string = workspaceRoot ) {
@@ -51,9 +55,9 @@ function getIgnoredGlobsFromFile(file: string, root?: string): string[] {
5155 continue ;
5256 } else if ( trimmed . startsWith ( '/' ) ) {
5357 if ( root ) {
54- results . push ( join ( root , trimmed ) ) ;
58+ results . push ( joinPathFragments ( root , trimmed ) ) ;
5559 } else {
56- results . push ( join ( '.' , trimmed ) ) ;
60+ results . push ( joinPathFragments ( '.' , trimmed ) ) ;
5761 }
5862 } else {
5963 results . push ( trimmed ) ;
0 commit comments