()
| 163 | // Notify Update |
| 164 | // |
| 165 | async notifyUpdate () { |
| 166 | try { |
| 167 | const store = this.openStore() |
| 168 | if (!store) return |
| 169 | |
| 170 | logger.debug('checking if update available') |
| 171 | |
| 172 | const lastCheck = Number(this.readDotenvxSetting('VERSION_LAST_CHECK') || 0) |
| 173 | const now = Date.now() |
| 174 | |
| 175 | if ((lastCheck + HOURS_24) >= now) return |
| 176 | |
| 177 | let remote = packageJson.version |
| 178 | |
| 179 | try { |
| 180 | logger.debug('fetching latest available dotenvx version') |
| 181 | const response = await http(VERSION_URL) |
| 182 | remote = normalizeVersion(await response.body.text()) |
| 183 | logger.debug(`latest dotenvx version: ${remote}`) |
| 184 | store.set(DOTENVX.VERSION, remote) |
| 185 | } catch (error) { |
| 186 | logger.debug(error.message) |
| 187 | } |
| 188 | |
| 189 | store.set(DOTENVX.VERSION_LAST_CHECK, now) |
| 190 | |
| 191 | if (versionGreaterThan(remote, packageJson.version)) { |
| 192 | console.error('⛆ update available [npm install @dotenvx/dotenvx@latest]') |
| 193 | } |
| 194 | } catch (error) { |
| 195 | logger.debug(error.message) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // |
| 200 | // armor status helpers |
no test coverage detected