Skip to content

Instantly share code, notes, and snippets.

@jon49
Last active December 3, 2017 21:23
Show Gist options
  • Save jon49/0940bcba98c4dce8da7a89cc66dd52a4 to your computer and use it in GitHub Desktop.
Save jon49/0940bcba98c4dce8da7a89cc66dd52a4 to your computer and use it in GitHub Desktop.
See the earliest F# file you have written
open System.IO
let sourceDir = [ __SOURCE_DIRECTORY__ ]
let getFiles searchPattern dir =
seq {
yield! Directory.EnumerateFiles(dir, searchPattern)
}
let log x =
printfn "%A" x
x
// http://www.fssnip.net/pi/title/Recursively-find-all-files-from-a-sequence-of-directories
let rec getAllFiles f dirs =
if Seq.isEmpty dirs then Seq.empty else
seq { yield! dirs |> Seq.collect f
yield! dirs
|> Seq.collect Directory.EnumerateDirectories
|> Seq.filter (fun x ->
let dirName = Path.GetFileName x
[ "node_modules"; ".git"; "bin"; "obj"; "vendors"; "themes"; "packages"; "VisualStudio2010" ]
|> List.contains dirName
|> not )
|> fun x -> if Seq.isEmpty x then Seq.empty else (getAllFiles f x) }
let getFileDates () =
let FSharp = getFiles "*.fs?"
getAllFiles FSharp sourceDir
|> Seq.map (fun x ->
let creationTime = File.GetLastWriteTime x
x, creationTime
)
|> Seq.toArray
do
getFileDates ()
|> Seq.minBy ( fun (filename, date) -> date )
|> (printfn "%A")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment