-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some logic to write relative instead of absolute paths to cache, f…
…ixes #1924
- Loading branch information
Showing
4 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
/// Contains basic functions for string manipulation. | ||
module Fake.Runtime.Path | ||
open System | ||
open System.IO | ||
|
||
// Normalizes path for different OS | ||
let inline normalizePath (path : string) = | ||
path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar) | ||
|
||
let getCurrentDirectory () = | ||
System.IO.Directory.GetCurrentDirectory() | ||
System.IO.Directory.GetCurrentDirectory() | ||
|
||
let private nugetDir = Path.GetFullPath(Paket.Constants.UserNuGetPackagesFolder).TrimEnd([|'/' ;'\\'|]) + "/" | ||
let fixPathForCache scriptPath (s:string) = | ||
let norm = Path.GetFullPath s | ||
if norm.StartsWith(nugetDir, if Paket.Utils.isWindows then StringComparison.OrdinalIgnoreCase else StringComparison.Ordinal) then | ||
sprintf "nugetcache://%s" (norm.Substring (nugetDir.Length)) | ||
else | ||
let scriptDir = Uri(Path.GetDirectoryName scriptPath + "/") | ||
let other = Uri(s) | ||
let rel = scriptDir.MakeRelativeUri(other) | ||
if rel.IsAbsoluteUri then rel.AbsoluteUri | ||
else | ||
sprintf "scriptpath:///%s" rel.OriginalString | ||
|
||
let readPathFromCache scriptPath (s:string) = | ||
let uri = Uri(s) | ||
if uri.Scheme = "nugetcache" then | ||
let rel = uri.AbsolutePath.TrimStart [| '/'|] | ||
Path.Combine (nugetDir, rel) | ||
elif uri.Scheme = "scriptpath" then | ||
let rel = uri.OriginalString.Substring("scriptpath:///".Length) | ||
Path.Combine(Path.GetDirectoryName scriptPath, rel) | ||
else | ||
uri.AbsolutePath |