@@ -11,20 +11,30 @@ const checkArrayExpectation = require("./checkArrayExpectation");
11
11
const Stats = require ( "../lib/Stats" ) ;
12
12
const webpack = require ( "../lib/webpack" ) ;
13
13
14
- function copyDiff ( src , dest ) {
14
+ function copyDiff ( src , dest , initial ) {
15
15
if ( ! fs . existsSync ( dest ) ) fs . mkdirSync ( dest ) ;
16
16
const files = fs . readdirSync ( src ) ;
17
17
files . forEach ( filename => {
18
18
const srcFile = path . join ( src , filename ) ;
19
19
const destFile = path . join ( dest , filename ) ;
20
20
const directory = fs . statSync ( srcFile ) . isDirectory ( ) ;
21
21
if ( directory ) {
22
- copyDiff ( srcFile , destFile ) ;
22
+ copyDiff ( srcFile , destFile , initial ) ;
23
23
} else {
24
24
var content = fs . readFileSync ( srcFile ) ;
25
- if ( / ^ D E L E T E \s * $ / . test ( content . toString ( "utf-8" ) ) )
25
+ if ( / ^ D E L E T E \s * $ / . test ( content . toString ( "utf-8" ) ) ) {
26
26
fs . unlinkSync ( destFile ) ;
27
- else fs . writeFileSync ( destFile , content ) ;
27
+ } else {
28
+ fs . writeFileSync ( destFile , content ) ;
29
+ if ( initial ) {
30
+ const longTimeAgo = Date . now ( ) - 1000 * 60 * 60 * 24 ;
31
+ fs . utimesSync (
32
+ destFile ,
33
+ Date . now ( ) - longTimeAgo ,
34
+ Date . now ( ) - longTimeAgo
35
+ ) ;
36
+ }
37
+ }
28
38
}
29
39
} ) ;
30
40
}
@@ -135,7 +145,7 @@ describe("WatchTestCases", () => {
135
145
let lastHash = "" ;
136
146
const currentWatchStepModule = require ( "./helpers/currentWatchStep" ) ;
137
147
currentWatchStepModule . step = run . name ;
138
- copyDiff ( path . join ( testDirectory , run . name ) , tempDirectory ) ;
148
+ copyDiff ( path . join ( testDirectory , run . name ) , tempDirectory , true ) ;
139
149
140
150
setTimeout ( ( ) => {
141
151
const compiler = webpack ( options ) ;
@@ -304,7 +314,8 @@ describe("WatchTestCases", () => {
304
314
currentWatchStepModule . step = run . name ;
305
315
copyDiff (
306
316
path . join ( testDirectory , run . name ) ,
307
- tempDirectory
317
+ tempDirectory ,
318
+ false
308
319
) ;
309
320
} , 1500 ) ;
310
321
} else {
0 commit comments