mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 07:33:17 +00:00
Merge pull request #8615 from strapi/fix/update-notif-file-access
Fix write access error of the update-notifier
This commit is contained in:
commit
c4e681e017
@ -1,12 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const packageJson = require('package-json');
|
||||
const Configstore = require('configstore');
|
||||
const semver = require('semver');
|
||||
const boxen = require('boxen');
|
||||
const chalk = require('chalk');
|
||||
const path = require('path');
|
||||
const pkg = require('../../../package');
|
||||
const { env } = require('strapi-utils');
|
||||
|
||||
const pkg = require('../../../package');
|
||||
|
||||
const CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 1; // 1 day
|
||||
const NOTIF_INTERVAL = 1000 * 60 * 60 * 24 * 7; // 1 week
|
||||
const boxenOptions = {
|
||||
@ -29,11 +32,18 @@ Check out the new the releases at: ${releaseLink}
|
||||
};
|
||||
|
||||
const createUpdateNotifier = strapi => {
|
||||
const config = new Configstore(
|
||||
pkg.name,
|
||||
{},
|
||||
{ configPath: path.join(strapi.dir, '.strapi-updater.json') }
|
||||
);
|
||||
let config = null;
|
||||
|
||||
try {
|
||||
config = new Configstore(
|
||||
pkg.name,
|
||||
{},
|
||||
{ configPath: path.join(strapi.dir, '.strapi-updater.json') }
|
||||
);
|
||||
} catch {
|
||||
// we don't have write access to the file system
|
||||
// we silence the error
|
||||
}
|
||||
|
||||
const checkUpdate = async checkInterval => {
|
||||
const now = Date.now();
|
||||
@ -74,7 +84,7 @@ const createUpdateNotifier = strapi => {
|
||||
|
||||
return {
|
||||
notify({ checkInterval = CHECK_INTERVAL, notifInterval = NOTIF_INTERVAL } = {}) {
|
||||
if (env.bool('STRAPI_DISABLE_UPDATE_NOTIFICATION', false)) {
|
||||
if (env.bool('STRAPI_DISABLE_UPDATE_NOTIFICATION', false) || !config) {
|
||||
return;
|
||||
}
|
||||
display(notifInterval);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user