File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ export async function copy(src: string, dest: string): Promise<void> {
38
38
if ( await exists ( dest ) ) {
39
39
let destStat = await lstat ( dest ) ;
40
40
41
- if ( srcStat . isFile ( ) && destStat . isFile ( ) && srcStat . size === destStat . size ) {
41
+ if ( srcStat . isFile ( ) && destStat . isFile ( ) &&
42
+ srcStat . size === destStat . size && + srcStat . mtime === + destStat . mtime ) {
42
43
// we can safely assume this is the same file
43
44
return ;
44
45
}
@@ -82,12 +83,18 @@ export async function copy(src: string, dest: string): Promise<void> {
82
83
readStream . on ( "error" , reject ) ;
83
84
writeStream . on ( "error" , reject ) ;
84
85
85
- writeStream . on ( "open" , function ( ) {
86
+ writeStream . on ( "open" , function ( ) {
86
87
readStream . pipe ( writeStream ) ;
87
88
} ) ;
88
89
89
- writeStream . once ( "finish" , function ( ) {
90
- resolve ( ) ;
90
+ writeStream . once ( "finish" , function ( ) {
91
+ fs . utimes ( dest , + srcStat . atime , + srcStat . mtime , function ( err ) {
92
+ if ( err ) {
93
+ reject ( err ) ;
94
+ } else {
95
+ resolve ( ) ;
96
+ }
97
+ } ) ;
91
98
} ) ;
92
99
} ) ;
93
100
} else {
You can’t perform that action at this time.
0 commit comments