(npm, spec = '*')
| 67 | } |
| 68 | |
| 69 | const 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 | |
| 100 | module.exports = async npm => { |
| 101 | if ( |
no test coverage detected
searching dependent graphs…