MCPcopy Index your code
hub / github.com/nodejs/node / updateNotifier

Function updateNotifier

deps/npm/lib/cli/update-notifier.js:69–98  ·  view source on GitHub ↗
(npm, spec = '*')

Source from the content-addressed store, hash-verified

67}
68
69const updateNotifier = async (npm, spec = '*') => {
70 // if we're on a prerelease train, then updates are coming fast check for a new one daily.
71 // otherwise, weekly.
72 const { version } = npm
73 const current = parse(version)
74
75 // if we're on a beta train, always get the next beta
76 if (current.prerelease.length) {
77 spec = `^${version}`
78 }
79
80 // while on a beta train, get updates daily
81 const duration = current.prerelease.length ? DAILY : WEEKLY
82
83 const t = new Date(Date.now() - duration)
84 // if we don't have a file, then definitely check it.
85 const st = await stat(lastCheckedFile(npm)).catch(() => ({ mtime: t - 1 }))
86
87 // if we've already checked within the specified duration, don't check again
88 if (!(t > st.mtime)) {
89 return null
90 }
91
92 // intentional. do not await this. it's a best-effort update.
93 // if this fails, it's ok.
94 // might be using /dev/null as the cache or something weird like that.
95 writeFile(lastCheckedFile(npm), '').catch(() => {})
96
97 return updateCheck(npm, spec, version, current)
98}
99
100module.exports = async npm => {
101 if (

Callers 4

entry.jsFile · 0.85
updateCheckFunction · 0.85
update-notifier.jsFile · 0.85
runUpdateNotifierFunction · 0.85

Calls 6

lastCheckedFileFunction · 0.85
updateCheckFunction · 0.85
nowMethod · 0.80
parseFunction · 0.50
statFunction · 0.50
writeFileFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…