@@ -6381,9 +6381,12 @@ namespace ts {
6381
6381
const aParts = getPathComponents ( getNormalizedAbsolutePath ( a , cwd ) ) ;
6382
6382
const bParts = getPathComponents ( getNormalizedAbsolutePath ( b , cwd ) ) ;
6383
6383
let isDirectory = false ;
6384
- while ( ! isNodeModulesOrScopedPackageDirectory ( aParts [ aParts . length - 2 ] , getCanonicalFileName ) &&
6384
+ while (
6385
+ aParts . length >= 2 && bParts . length >= 2 &&
6386
+ ! isNodeModulesOrScopedPackageDirectory ( aParts [ aParts . length - 2 ] , getCanonicalFileName ) &&
6385
6387
! isNodeModulesOrScopedPackageDirectory ( bParts [ bParts . length - 2 ] , getCanonicalFileName ) &&
6386
- getCanonicalFileName ( aParts [ aParts . length - 1 ] ) === getCanonicalFileName ( bParts [ bParts . length - 1 ] ) ) {
6388
+ getCanonicalFileName ( aParts [ aParts . length - 1 ] ) === getCanonicalFileName ( bParts [ bParts . length - 1 ] )
6389
+ ) {
6387
6390
aParts . pop ( ) ;
6388
6391
bParts . pop ( ) ;
6389
6392
isDirectory = true ;
@@ -6393,8 +6396,8 @@ namespace ts {
6393
6396
6394
6397
// KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
6395
6398
// ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked.
6396
- function isNodeModulesOrScopedPackageDirectory ( s : string , getCanonicalFileName : GetCanonicalFileName ) : boolean {
6397
- return getCanonicalFileName ( s ) === "node_modules" || startsWith ( s , "@" ) ;
6399
+ function isNodeModulesOrScopedPackageDirectory ( s : string | undefined , getCanonicalFileName : GetCanonicalFileName ) : boolean {
6400
+ return s !== undefined && ( getCanonicalFileName ( s ) === "node_modules" || startsWith ( s , "@" ) ) ;
6398
6401
}
6399
6402
6400
6403
function stripLeadingDirectorySeparator ( s : string ) : string | undefined {
0 commit comments