@@ -6381,9 +6381,12 @@ namespace ts {
63816381 const aParts = getPathComponents ( getNormalizedAbsolutePath ( a , cwd ) ) ;
63826382 const bParts = getPathComponents ( getNormalizedAbsolutePath ( b , cwd ) ) ;
63836383 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 ) &&
63856387 ! 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+ ) {
63876390 aParts . pop ( ) ;
63886391 bParts . pop ( ) ;
63896392 isDirectory = true ;
@@ -6393,8 +6396,8 @@ namespace ts {
63936396
63946397 // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
63956398 // 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 , "@" ) ) ;
63986401 }
63996402
64006403 function stripLeadingDirectorySeparator ( s : string ) : string | undefined {
0 commit comments