Skip to content

Commit

Permalink
Allow all kinds of spaces in paket.dependencies - references #95
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Sep 17, 2014
1 parent 403f15f commit a8dc5a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Paket/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ module DependenciesFileParser =
let parts = trimmed.Split ' '
Remote (parts.[1].Replace("\"",""))
| trimmed when trimmed.StartsWith "nuget" ->
let parts = trimmed.Replace("nuget","").Trim().Replace("\"", "").Split ' ' |> Seq.toList
let parts = trimmed.Replace("nuget","").Trim().Replace("\"", "").Split([|' '|],StringSplitOptions.RemoveEmptyEntries) |> Seq.toList
match parts with
| name :: operator :: version :: _
when List.exists ((=) operator) operators -> Package(name,operator + " " + version)
| name :: version :: _ -> Package(name,version)
| _ -> failwithf "could not retrieve nuget package from %s" trimmed
| trimmed when trimmed.StartsWith "references" -> ReferencesMode(trimmed.Replace("references","").Trim() = "strict")
| trimmed when trimmed.StartsWith "github" ->
let parts = trimmed.Replace("\"", "").Split ' '
let parts = trimmed.Replace("\"", "").Trim().Split([|' '|],StringSplitOptions.RemoveEmptyEntries)
let getParts (projectSpec:string) =
match projectSpec.Split [|':'; '/'|] with
| [| owner; project |] -> owner, project, None
Expand Down
26 changes: 23 additions & 3 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,27 @@ nuget SignalR = 3.3.2
"""

[<Test>]
let ``should read config without "``() =
let ``should read config without quotes``() =
let cfg = DependenciesFile.FromCode configWithoutQuotes
cfg.Strict |> shouldEqual false
cfg.DirectDependencies.Count |> shouldEqual 4

cfg.DirectDependencies.["Rx-Main"] |> shouldEqual (VersionRange.Between("2.0", "3.0"))
cfg.DirectDependencies.["Castle.Windsor-log4net"] |> shouldEqual (VersionRange.Between("3.2", "4.0"))
cfg.DirectDependencies.["FAKE"] |> shouldEqual (VersionRange.Exactly "1.1")
cfg.DirectDependencies.["SignalR"] |> shouldEqual (VersionRange.Exactly "3.3.2")

let configWithoutQuotesButLotsOfWhiteSpace = """
source http://nuget.org/api/v2
nuget Castle.Windsor-log4net ~> 3.2
nuget Rx-Main ~> 2.0
nuget FAKE = 1.1
nuget SignalR = 3.3.2
"""

[<Test>]
let ``should read config without quotes but lots of whitespace``() =
let cfg = DependenciesFile.FromCode configWithoutQuotes
cfg.Strict |> shouldEqual false
cfg.DirectDependencies.Count |> shouldEqual 4
Expand All @@ -144,8 +164,8 @@ let ``should read config without "``() =

[<Test>]
let ``should read github source file from config without quotes``() =
let config = """github fsharp/FAKE src/app/FAKE/Cli.fs
github fsharp/FAKE:bla123zxc src/app/FAKE/FileWithCommit.fs """
let config = """github fsharp/FAKE src/app/FAKE/Cli.fs
github fsharp/FAKE:bla123zxc src/app/FAKE/FileWithCommit.fs """
let dependencies = DependenciesFile.FromCode config
dependencies.RemoteFiles
|> shouldEqual
Expand Down

0 comments on commit a8dc5a6

Please sign in to comment.