@@ -11,20 +11,30 @@ const { remove } = require("./helpers/remove");
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}
@@ -121,7 +131,7 @@ describe("WatchTestCases", () => {
121131 let lastHash = "" ;
122132 const currentWatchStepModule = require ( "./helpers/currentWatchStep" ) ;
123133 currentWatchStepModule . step = run . name ;
124- copyDiff ( path . join ( testDirectory , run . name ) , tempDirectory ) ;
134+ copyDiff ( path . join ( testDirectory , run . name ) , tempDirectory , true ) ;
125135
126136 setTimeout ( ( ) => {
127137 const compiler = webpack ( options ) ;
@@ -292,7 +302,8 @@ describe("WatchTestCases", () => {
292302 currentWatchStepModule . step = run . name ;
293303 copyDiff (
294304 path . join ( testDirectory , run . name ) ,
295- tempDirectory
305+ tempDirectory ,
306+ false
296307 ) ;
297308 } , 1500 ) ;
298309 } else {
0 commit comments