Skip to content

Commit

Permalink
Merge pull request #770 from Stift/FixGetHomeForLocalNuget
Browse files Browse the repository at this point in the history
Fixed home path detection
  • Loading branch information
forki committed Apr 13, 2015
2 parents 72fdf39 + d0b8ccd commit a0fdf6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Paket.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ let GetHomeDirectory() =
else
Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%")

let normalizeLocalPath(path:string) =
let normalizeLocalPath(path:string)=
if path.StartsWith("~/") then
Path.Combine(GetHomeDirectory(),path.Substring(1))
else
Path.Combine(GetHomeDirectory(), path.Substring(2))
else
path

/// Creates a directory if it does not exist.
let createDir path =
try
Expand Down
10 changes: 9 additions & 1 deletion tests/Paket.Tests/UtilsSpecs.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Paket.UtilsSpecs

open System.IO
open Paket
open NUnit.Framework
open FsUnit
Expand All @@ -8,4 +9,11 @@ open FsUnit
let ``createRelativePath should handle spaces``() =
"C:/some file"
|> createRelativePath "C:/a/b"
|> shouldEqual "..\\some file"
|> shouldEqual "..\\some file"


[<Test>]
let ``normalize path with home directory``() =
"~/data"
|> Utils.normalizeLocalPath
|> shouldEqual (GetHomeDirectory() + Path.DirectorySeparatorChar.ToString() + "data")

0 comments on commit a0fdf6f

Please sign in to comment.