@@ -4,13 +4,35 @@ import { type Project, tempdirProject } from "@typestrong/fs-fixture-builder";
4
4
import { type AssertionError , deepStrictEqual as equal } from "assert" ;
5
5
import { basename , dirname , resolve , normalize , join } from "path" ;
6
6
import {
7
+ deriveRootDir ,
7
8
getCommonDirectory ,
8
9
glob ,
9
10
inferPackageEntryPointPaths ,
10
11
} from "../../lib/utils/fs.js" ;
11
12
import { normalizePath } from "../../lib/utils/paths.js" ;
12
13
13
14
describe ( "fs.ts" , ( ) => {
15
+ describe ( "deriveRootDir" , ( ) => {
16
+ it ( "Ignores glob parts of filenames" , ( ) => {
17
+ equal (
18
+ deriveRootDir ( [ "src/foo/**/*.ts" , "src/foo/**/*.tsx" ] ) ,
19
+ "src/foo" ,
20
+ ) ;
21
+
22
+ equal ( deriveRootDir ( [ "src/foo/**/*.ts" , "src/**/**/*.tsx" ] ) , "src" ) ;
23
+ } ) ;
24
+
25
+ it ( "Returns a fs path when path contains glob characters #2825" , ( ) => {
26
+ equal (
27
+ deriveRootDir ( [
28
+ "src/foo/\\[abc]/*.ts" ,
29
+ "src/foo/\\[abc]/sub/*.ts" ,
30
+ ] ) ,
31
+ "src/foo/[abc]" ,
32
+ ) ;
33
+ } ) ;
34
+ } ) ;
35
+
14
36
describe ( "getCommonDirectory" , ( ) => {
15
37
it ( "Returns the empty string if no files are provided" , ( ) => {
16
38
equal ( getCommonDirectory ( [ ] ) , "" ) ;
@@ -31,6 +53,10 @@ describe("fs.ts", () => {
31
53
"/a/b" ,
32
54
) ;
33
55
} ) ;
56
+
57
+ it ( "Does not respect Windows path sep #2825" , ( ) => {
58
+ equal ( getCommonDirectory ( [ "/a/b\\]/c" , "/a/b\\]/d" ] ) , "/a/b\\]" ) ;
59
+ } ) ;
34
60
} ) ;
35
61
36
62
describe ( "glob" , ( ) => {
0 commit comments