@@ -51,21 +51,37 @@ export async function getDirectoryNamesInsidePath(
5151 return dirNames ;
5252}
5353
54- export function pathsEqual (
55- path1 : string ,
56- path2 : string ,
57- platform : NodeJS . Platform ,
58- ) : boolean {
54+ function normalizePath ( path : string , platform : NodeJS . Platform ) : string {
5955 // On Windows, "C:/", "C:\", and "c:/" are all equivalent. We need
6056 // to normalize the paths to ensure they all get resolved to the
6157 // same format. On Windows, we also need to do the comparison
6258 // case-insensitively.
63- path1 = resolve ( path1 ) ;
64- path2 = resolve ( path2 ) ;
59+ path = resolve ( path ) ;
6560 if ( platform === "win32" ) {
66- return path1 . toLowerCase ( ) === path2 . toLowerCase ( ) ;
61+ path = path . toLowerCase ( ) ;
6762 }
68- return path1 === path2 ;
63+ return path ;
64+ }
65+
66+ export function pathsEqual (
67+ path1 : string ,
68+ path2 : string ,
69+ platform : NodeJS . Platform ,
70+ ) : boolean {
71+ return normalizePath ( path1 , platform ) === normalizePath ( path2 , platform ) ;
72+ }
73+
74+ /**
75+ * Returns true if path1 contains path2.
76+ */
77+ export function containsPath (
78+ path1 : string ,
79+ path2 : string ,
80+ platform : NodeJS . Platform ,
81+ ) : boolean {
82+ return normalizePath ( path2 , platform ) . startsWith (
83+ normalizePath ( path1 , platform ) ,
84+ ) ;
6985}
7086
7187export async function readDirFullPaths ( path : string ) : Promise < string [ ] > {
0 commit comments