Last active
April 8, 2018 19:55
-
-
Save jwosty/8f56d0ad2fb3919de7d27bf1bfb90c65 to your computer and use it in GitHub Desktop.
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
#if run_as_bin_sh | |
exec fsharpi --quiet --readline- < <(cat $0) -- $* | |
#endif | |
// Downloads the paket bootstrapper in magic mode into $PWD/.paket/ . | |
open System | |
open System.IO | |
open System.Net | |
open System.Text.RegularExpressions | |
let paketDir = Path.Combine [|Environment.CurrentDirectory; ".paket"|] | |
let paketExe = Path.Combine [|paketDir; "paket.exe"|] | |
let bootstrapperExeRegex = new Regex(@"""browser_download_url"":\s*""(?<url>[^""]*/paket.bootstrapper.exe)""") | |
let latestBootstrapperUrl (wc: WebClient) = | |
wc.Headers.Add ("user-agent", "fsharp-script") | |
let json = wc.DownloadString "https://api.github.com/repos/fsprojects/Paket/releases/latest" | |
(bootstrapperExeRegex.Match json).Groups.["url"].Value | |
let main () = | |
use wc = new WebClient () | |
printfn "Fetching latest paket release..." | |
let url = latestBootstrapperUrl wc | |
printfn "Saving paket bootstrapper as paket.exe (magic mode) in %s..." paketDir | |
Directory.CreateDirectory paketDir |> ignore | |
wc.DownloadFile (url, paketExe) | |
printfn "Done. Paket should now be working." | |
main () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment