@@ -10,7 +10,7 @@ module ProcessUtils =
10
10
11
11
/// Searches the given directories for all occurrences of the given file name
12
12
/// [omit]
13
- let findFiles dirs file =
13
+ let private findFilesInternal dirs file =
14
14
let files =
15
15
dirs
16
16
|> Seq.map ( fun ( path : string ) ->
@@ -35,6 +35,18 @@ module ProcessUtils =
35
35
|> Seq.cache
36
36
files
37
37
38
+ /// Searches the given directories for all occurrences of the given file name, on windows PATHEXT is considered (and preferred when searching)
39
+ let findFiles dirs file =
40
+ // See https://unix.stackexchange.com/questions/280528/is-there-a-unix-equivalent-of-the-windows-environment-variable-pathext
41
+ if Environment.isWindows then
42
+ // Prefer PATHEXT, see https://github.com/fsharp/FAKE/issues/1911
43
+ // and https://github.com/fsharp/FAKE/issues/1899
44
+ Environment.environVarOrDefault " PATHEXT" " .COM;.EXE;.BAT"
45
+ |> String.split ';'
46
+ |> Seq.collect ( fun postFix -> findFilesInternal dirs ( file + postFix))
47
+ |> fun findings -> Seq.append findings ( findFilesInternal dirs file)
48
+ else findFilesInternal dirs file
49
+
38
50
/// Searches the given directories for all occurrences of the given file name
39
51
/// [omit]
40
52
let tryFindFile dirs file =
@@ -54,16 +66,7 @@ module ProcessUtils =
54
66
Environment.pathDirectories
55
67
|> Seq.filter Path.isValidPath
56
68
|> Seq.append [ " ." ]
57
- |> fun path ->
58
- // See https://unix.stackexchange.com/questions/280528/is-there-a-unix-equivalent-of-the-windows-environment-variable-pathext
59
- if Environment.isWindows then
60
- // Prefer PATHEXT, see https://github.com/fsharp/FAKE/issues/1911
61
- // and https://github.com/fsharp/FAKE/issues/1899
62
- Environment.environVarOrDefault " PATHEXT" " .COM;.EXE;.BAT"
63
- |> String.split ';'
64
- |> Seq.collect ( fun postFix -> findFiles path ( file + postFix))
65
- |> fun findings -> Seq.append findings ( findFiles path file)
66
- else findFiles path file
69
+ |> fun dirs -> findFiles dirs file
67
70
68
71
/// Searches the current directory and the directories within the PATH
69
72
/// environment variable for the given file. If successful returns the full
@@ -92,4 +95,4 @@ module ProcessUtils =
92
95
let findPath fallbackValue tool =
93
96
match tryFindPath fallbackValue tool with
94
97
| Some file -> file
95
- | None -> tool
98
+ | None -> tool
0 commit comments