Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit 8cd64d8

Browse files
committed
Bug fixed
1 parent 363251c commit 8cd64d8

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

Bake.Actions/Copy.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ let copyFileTask (echo: string option) script srcFile dstFile = {
1010
| None -> ()
1111
let dstDir = FileInfo(dstFile).Directory
1212
if not dstDir.Exists then dstDir.Create ()
13-
File.Copy (srcFile, dstFile)
13+
let bytes = File.ReadAllBytes srcFile
14+
File.WriteAllBytes (dstFile, bytes)
1415

1516
inputFiles = seq { FileInfo (srcFile) }
1617
source = script

Bake.Core/Task.fs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ type Task = {
1515
}
1616

1717
module Task =
18-
let isDirty x = true // Task -> bool
18+
let isDirty x =
19+
try
20+
if x.dirty || x.inputFiles |> Seq.isEmpty || x.outputFiles |> Seq.isEmpty then true // 如果input、output为空或者设置了强制ditry
21+
else if x.outputFiles |> Seq.exists (System.IO.File.Exists >> not) then true // 如果存在未被生成的文件
22+
else
23+
let newestInputFiles =
24+
seq { yield! x.inputFiles; yield x.source.scriptFile } |> Seq.maxBy (fun (x: FileInfo) -> x.LastWriteTimeUtc)
25+
let oldestOutputFiles =
26+
x.outputFiles |> Seq.map FileInfo |> Seq.minBy (fun x -> x.LastWriteTimeUtc)
27+
if newestInputFiles.LastWriteTimeUtc > oldestOutputFiles.LastWriteTimeUtc then true
28+
else false
29+
with _ -> true
30+
1931

2032
let run (task: Task) : Result<unit, exn> =
2133
if isDirty task then

Bake/Program.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ let main args =
6565
printfn "Error:%A" e
6666
-1
6767

68-
// Next: 实现Dirty判断
6968
// Next: 实现以下Action
7069
// * If
7170
// * Equals $a $b

Publish.bake

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ Run {
1818

1919
CreateDirectory {
2020
$Output
21-
$Output/src-$DateTime
22-
23-
$Output/src-$DateTime/Bake
24-
$Output/src-$DateTime/Bake.Core
25-
$Output/src-$DateTime/Bake.Actions
26-
$Output/src-$DateTime/Bake.Parser
21+
$Output/src
22+
$Output/src/Bake
23+
$Output/src/Bake.Core
24+
$Output/src/Bake.Actions
25+
$Output/src/Bake.Parser
2726
}
2827

2928
Action CopyProject projectName {
30-
Copy "$Output/src-$DateTime/projectName" {
29+
Copy "$Output/src/projectName" {
3130
projectName/*.fs
3231
projectName/*.fsproj
3332
projectName/Properties
@@ -56,7 +55,7 @@ Parallel {
5655
CopyProject Bake
5756

5857

59-
Copy "$Output/src-$DateTime" {
58+
Copy "$Output/src" {
6059
LICENSE
6160
Bake.sln
6261
Package.bake
@@ -65,7 +64,7 @@ Parallel {
6564
}
6665

6766
Zip "$Output/Bake-src-$DateTime.zip" {
68-
$Output/src-$DateTime/*
67+
$Output/src/*
6968
}
7069
}
7170
}

0 commit comments

Comments
 (0)