Skip to content

Commit

Permalink
Update: Handle dates consistently (fixes #191)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman authored and phated committed Nov 30, 2017
1 parent 20fc47c commit c11dcbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
21 changes: 8 additions & 13 deletions lib/file-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var util = require('util');
var fs = require('graceful-fs');
var path = require('path');
var assign = require('object-assign');
var isValidDate = require('vali-date');
var date = require('value-or-function').date;
var FlushWriteStream = require('flush-write-stream');

var constants = require('./constants');
Expand Down Expand Up @@ -52,24 +52,19 @@ function getModeDiff(fsMode, vinylMode) {

function getTimesDiff(fsStat, vinylStat) {

if (!isValidDate(vinylStat.mtime)) {
var mtime = date(vinylStat.mtime);
if (!mtime) {
return;
}

if (+vinylStat.mtime === +fsStat.mtime &&
+vinylStat.atime === +fsStat.atime) {
var atime = date(vinylStat.atime);
if (+mtime === +fsStat.mtime &&
+atime === +fsStat.atime) {
return;
}

var atime;
if (isValidDate(vinylStat.atime)) {
atime = vinylStat.atime;
} else {
atime = fsStat.atime;
}

if (!isValidDate(atime)) {
atime = undefined;
if (!atime) {
atime = date(fsStat.atime) || undefined;
}

var timesDiff = {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
"strip-bom-stream": "^1.0.0",
"through2": "^2.0.0",
"through2-filter": "^2.0.0",
"vali-date": "^1.0.0",
"value-or-function": "^1.2.0",
"value-or-function": "^2.0.0",
"vinyl": "^2.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit c11dcbd

Please sign in to comment.