@@ -487,12 +487,12 @@ function assertExtraConfigTypes(extraConfigTypes) {
487
487
}
488
488
489
489
/**
490
- * Determines if an absolute path is a POSIX path.
490
+ * Returns path-handling implementations for Unix or Windows, depending on a given absolute path.
491
491
* @param {string } path The absolute path to check.
492
- * @returns {boolean } Whether the specified path is a POSIX path.
492
+ * @returns {typeof import("@jsr/std__path") } Path-handling implementations for the specified path.
493
493
*/
494
- function isPosixPath ( path ) {
495
- return path . startsWith ( "/" ) ;
494
+ function getPathImpl ( path ) {
495
+ return path . startsWith ( "/" ) ? posixPath : windowsPath ;
496
496
}
497
497
498
498
//------------------------------------------------------------------------------
@@ -600,11 +600,7 @@ export class ConfigArray extends Array {
600
600
// The namespaced base path is useful to make sure that calculated relative paths are always relative.
601
601
// On Unix, it is identical to the base path.
602
602
this . namespacedBasePath =
603
- basePath &&
604
- ( isPosixPath ( this . basePath )
605
- ? posixPath
606
- : windowsPath
607
- ) . toNamespacedPath ( basePath ) ;
603
+ basePath && getPathImpl ( this . basePath ) . toNamespacedPath ( basePath ) ;
608
604
}
609
605
610
606
/**
@@ -808,16 +804,14 @@ export class ConfigArray extends Array {
808
804
return cache . get ( filePath ) ;
809
805
}
810
806
811
- // Select `path` implementations depending on base path.
812
- // If base path is not specified, relative paths cannot be built.
813
- // In this case, `path` implementations are selected depending on the specified argument.
814
- const path = isPosixPath ( this . basePath || filePath )
815
- ? posixPath
816
- : windowsPath ;
807
+ // Select path-handling implementations depending on the specified file path.
808
+ const path = getPathImpl ( filePath ) ;
817
809
818
810
// check to see if the file is outside the base path
819
811
820
812
const namespacedFilePath = path . toNamespacedPath ( filePath ) ;
813
+
814
+ // If base path is not specified, relative paths cannot be built.
821
815
const relativeFilePath = (
822
816
this . namespacedBasePath
823
817
? path . relative ( this . namespacedBasePath , namespacedFilePath )
@@ -1038,14 +1032,12 @@ export class ConfigArray extends Array {
1038
1032
isDirectoryIgnored ( directoryPath ) {
1039
1033
assertNormalized ( this ) ;
1040
1034
1041
- // Select `path` implementations depending on base path.
1042
- // If base path is not specified, relative paths cannot be built.
1043
- // In this case, `path` implementations are selected depending on the specified argument.
1044
- const path = isPosixPath ( this . basePath || directoryPath )
1045
- ? posixPath
1046
- : windowsPath ;
1035
+ // Select path-handling implementations depending on the specified directory path.
1036
+ const path = getPathImpl ( directoryPath ) ;
1047
1037
1048
1038
const namespacedDirectoryPath = path . toNamespacedPath ( directoryPath ) ;
1039
+
1040
+ // If base path is not specified, relative paths cannot be built.
1049
1041
const relativeDirectoryPath = (
1050
1042
this . namespacedBasePath
1051
1043
? path . relative (
0 commit comments