Skip to content

Commit

Permalink
setDeferred(): detect properTime (standard-things#832)
Browse files Browse the repository at this point in the history
For `npm pack`ed modules, the mtime is ancient and so we use ctime instead
  • Loading branch information
michaelfig authored and jdalton committed Sep 26, 2019
1 parent 4f35a24 commit 511d672
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ const PUPPETEER_EXECUTION_CONTEXT_PATH_SEGMENT = sep + "lib" + sep + "ExecutionC
const PUPPETEER_PACKAGE_PATH_SEGMENT = sep + "puppeteer" + sep
const PUPPETEER_UPPERCASE_E_CHAR_OFFSET = -19

// Detect packages installed via NPM that have an mtime of
// 1985-10-26T08:15Z
const A_LONG_TIME_AGO_MS = new Date("1985-10-27T00:00Z").getTime()

const pseudoDescriptor = {
value: true
}
Expand Down Expand Up @@ -429,7 +433,12 @@ class Entry {
const stat = statSync(filename)

if (stat !== null) {
return getStatTimestamp(stat, "mtime")
// If the mtime is long ago, use the ctime instead.
let properTime = getStatTimestamp(stat, "mtime")
if (properTime < A_LONG_TIME_AGO_MS) {
properTime = getStatTimestamp(stat, "ctime")
}
return properTime
}
}

Expand Down

0 comments on commit 511d672

Please sign in to comment.