Skip to content

Commit 8892d04

Browse files
committed
Merge pull request #956 from xavierzwirtz/path-cache-bust
Script path cache bust
2 parents 7839481 + d57ebed commit 8892d04

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/app/FakeLib/EnvironmentHelper.fs

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ let inline combinePathsNoTrim path1 path2 = Path.Combine(path1, path2)
2525
let inline (@@) path1 path2 = combinePaths path1 path2
2626
let inline (</>) path1 path2 = combinePathsNoTrim path1 path2
2727

28+
// Normalizes path for different OS
29+
let inline normalizePath (path : string) =
30+
path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)
31+
2832
/// Retrieves all environment variables from the given target
2933
let environVars target =
3034
[ for e in Environment.GetEnvironmentVariables target ->

src/app/FakeLib/FSIHelper.fs

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ let rec getAllScripts scriptPath : seq<Script> =
7070

7171
let getScriptHash pathsAndContents =
7272
let fullContents = getAllScriptContents pathsAndContents |> String.concat "\n"
73+
let paths = pathsAndContents |> Seq.map(fun x -> x.Location |> EnvironmentHelper.normalizePath) |> String.concat "\n"
74+
7375
let hasher = HashLib.HashFactory.Checksum.CreateCRC32a()
74-
hasher.ComputeString(fullContents).ToString()
76+
hasher.ComputeString(fullContents + paths).ToString()
7577

7678
module private Cache =
7779
let xname name = XName.Get(name)

src/app/FakeLib/Globbing/Globbing.fs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// This module contains a file pattern globbing implementation.
22
module Fake.Globbing
33

4+
open Fake.EnvironmentHelper
45
open System
56
open System.Collections.Generic
67
open System.IO
@@ -58,8 +59,6 @@ let private isDrive =
5859
let regex = Regex(@"^[A-Za-z]:$", RegexOptions.Compiled)
5960
fun dir -> regex.IsMatch dir
6061

61-
let inline private normalizePath (p : string) =
62-
p.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)
6362
let inline private normalizeOutputPath (p : string) =
6463
p.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)
6564
.TrimEnd(Path.DirectorySeparatorChar)

src/test/Test.FAKECore/ChangeWatcherSpecs.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class when_calculating_directories_to_watch
1616
var dirsToWatch = ChangeWatcher.calcDirsToWatch(fileIncludes);
1717

1818
dirsToWatch.Length.ShouldEqual(2);
19-
dirsToWatch.ShouldContain(Fake.Globbing.normalizePath(@"C:\Project\test1\bin"));
20-
dirsToWatch.ShouldContain(Fake.Globbing.normalizePath(@"C:\Project\test2\bin"));
19+
dirsToWatch.ShouldContain(Fake.EnvironmentHelper.normalizePath(@"C:\Project\test1\bin"));
20+
dirsToWatch.ShouldContain(Fake.EnvironmentHelper.normalizePath(@"C:\Project\test2\bin"));
2121
};
2222

2323
It should_only_take_the_most_root_path_when_multiple_directories_share_a_root =
@@ -29,7 +29,7 @@ public class when_calculating_directories_to_watch
2929
var dirsToWatch = ChangeWatcher.calcDirsToWatch(fileIncludes);
3030

3131
dirsToWatch.Length.ShouldEqual(1);
32-
dirsToWatch.ShouldContain(Fake.Globbing.normalizePath(@"C:\Project\tests"));
32+
dirsToWatch.ShouldContain(Fake.EnvironmentHelper.normalizePath(@"C:\Project\tests"));
3333
};
3434
}
3535
}

0 commit comments

Comments
 (0)