Skip to content

Commit a6b5dc5

Browse files
committed
Merge branch 'dev'
2 parents bdcb773 + d51673b commit a6b5dc5

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

XakeLibTests/FilesetTests.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ type FilesetTests() =
9393
fileNames |> List.iter System.Console.WriteLine
9494
Assert.That (fileNames, Is.All.EndsWith("rdl"))
9595

96+
[<Test (Description = "Verifies ls could search for directories")>]
97+
member o.LsDirs() =
98+
99+
let files = ls "c:/*/" |> getFiles1 root1 @"c:\rpt"
100+
Assert.That (files |> List.map name, Is.EquivalentTo (List.toSeq ["bak"; "rpt"; "jparsec"]))
101+
96102
[<Test>]
97103
member o.Builder() =
98104
let fileset = fileset {

core/Fileset.fs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,7 @@ module Fileset =
131131
fsroot @ (Array.map mapPart parts |> List.ofArray) @ filepart
132132
|> Pattern |> normalize
133133

134-
/// Parses file mask
135-
let parseFileMask = parseDirFileMask false
136-
137-
/// Parses file mask
138-
let parseDir = parseDirFileMask true
139-
134+
140135
let FileSystem = {
141136
GetDisk = fun d -> d + Path.DirectorySeparatorChar.ToString()
142137
GetDirRoot = fun x -> Directory.GetDirectoryRoot x
@@ -213,7 +208,7 @@ module Fileset =
213208

214209
/// Returns true if a file name (parsedto p) matches specific file mask.
215210
let matchesPattern (Pattern mask) file =
216-
let (Pattern fileParts) = parseFileMask file in
211+
let (Pattern fileParts) = (parseDirFileMask false) file in
217212
matchPathsImpl mask fileParts
218213

219214
let private ifNone v2 = function | None -> v2 | Some v -> v
@@ -222,7 +217,7 @@ module Fileset =
222217
/// "Materializes" fileset to a filelist
223218
let scan fileSystem root (Fileset (options,filesetItems)) =
224219

225-
let startDirPat = options.BaseDir |> ifNone root |> parseDir
220+
let startDirPat = options.BaseDir |> ifNone root |> parseDirFileMask true
226221
let startDir = startDirPat |> cd fileSystem "."
227222

228223
// TODO check performance, build function
@@ -317,7 +312,8 @@ module Fileset =
317312
/// </summary>
318313
/// <param name="filePattern"></param>
319314
let ls (filePattern:FilePattern) =
320-
Fileset (DefaultOptions, [filePattern |> parseFileMask |> Includes])
315+
let parse = (filePattern.EndsWith ("/") || filePattern.EndsWith ("\\")) |> Impl.parseDirFileMask
316+
Fileset (DefaultOptions, [filePattern |> parse |> Includes])
321317

322318
/// <summary>
323319
/// Create a file set for specific file mask. The same as "ls"
@@ -355,7 +351,7 @@ module Fileset =
355351
// matches "src/**/*.cs" "c:\!\src\a\b\c.cs" -> true
356352

357353
// TODO alternative implementation, convert pattern to a match function using combinators
358-
Impl.matchesPattern <| joinPattern (parseDir rootPath) (parseFileMask filePattern)
354+
Impl.matchesPattern <| joinPattern (parseDirMask rootPath) (parseFileMask filePattern)
359355

360356
let FileSystem = Impl.FileSystem
361357

docs/overview.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,15 @@ In the sample above `cp` function ensures the source file is build before it's c
286286

287287
### Filesets
288288

289-
### Internal functions
289+
* `getFiles` - (only allowed inside action) returns list of files specified by a fileset
290+
* `ls` - creates a fileset for specified file mask. In case mask ends with "/" or "\" it returns directory list
291+
292+
File masks follow Ant/Fake rules.
293+
294+
### Other functions
290295

291-
* `need '['<targets...>']'`
292296
* `trace <level> <format> <args...>`
293-
* `getCtxOptions`
297+
* `getCtxOptions` - gets action context
294298
* `getVar <varname>` - gets the variable value (and records dependency!)
295299
* `getEnv <varname>` - gets environment variable (and records dependency!)
296300
* `alwaysRerun` - instructs Xake to rebuild the target even if dependencies are not changed

docs/todo.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* rule "Viewer" -> fun folder -> action {need [folder <\\> "bin" <\\> folder <.> "exe"]...}
2828

2929
## Done
30+
* ls returns directory list in case it ends with "/" ("\")
3031
* MSBuild task
3132
* performance of rules lookup (takes 2s now)
3233
* FSC task (f# compiler), self bootstrap

0 commit comments

Comments
 (0)