Created
October 2, 2016 21:20
-
-
Save vbfox/0cfc602eab588e0660af63d854ce73fe to your computer and use it in GitHub Desktop.
F# module for WindowsPath access (Useful in FAKE scripts)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WindowsPath = | |
open System | |
open System.IO | |
let path = lazy (Environment.GetEnvironmentVariable("PATH").Split(';') |> List.ofArray) | |
let pathExt = lazy (Environment.GetEnvironmentVariable("PATHEXT").Split(';') |> List.ofArray) | |
let find names = | |
path.Value | |
|> Seq.collect (fun dir -> names |> List.map (fun name -> Path.Combine(dir, name))) | |
|> Seq.tryFind(File.Exists) | |
let findProgram name = | |
pathExt.Value | |
|> List.map ((+) name) | |
|> find |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment