@@ -11,20 +11,30 @@ const checkArrayExpectation = require("./checkArrayExpectation");
1111const Stats = require ( "../lib/Stats" ) ;
1212const webpack = require ( "../lib/webpack" ) ;
1313
14- function copyDiff ( src , dest ) {
14+ function copyDiff ( src , dest , initial ) {
1515 if ( ! fs . existsSync ( dest ) ) fs . mkdirSync ( dest ) ;
1616 const files = fs . readdirSync ( src ) ;
1717 files . forEach ( filename => {
1818 const srcFile = path . join ( src , filename ) ;
1919 const destFile = path . join ( dest , filename ) ;
2020 const directory = fs . statSync ( srcFile ) . isDirectory ( ) ;
2121 if ( directory ) {
22- copyDiff ( srcFile , destFile ) ;
22+ copyDiff ( srcFile , destFile , initial ) ;
2323 } else {
2424 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" ) ) ) {
2626 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+ }
2838 }
2939 } ) ;
3040}
@@ -135,7 +145,7 @@ describe("WatchTestCases", () => {
135145 let lastHash = "" ;
136146 const currentWatchStepModule = require ( "./helpers/currentWatchStep" ) ;
137147 currentWatchStepModule . step = run . name ;
138- copyDiff ( path . join ( testDirectory , run . name ) , tempDirectory ) ;
148+ copyDiff ( path . join ( testDirectory , run . name ) , tempDirectory , true ) ;
139149
140150 setTimeout ( ( ) => {
141151 const compiler = webpack ( options ) ;
@@ -304,7 +314,8 @@ describe("WatchTestCases", () => {
304314 currentWatchStepModule . step = run . name ;
305315 copyDiff (
306316 path . join ( testDirectory , run . name ) ,
307- tempDirectory
317+ tempDirectory ,
318+ false
308319 ) ;
309320 } , 1500 ) ;
310321 } else {
0 commit comments