From 1be4237e4c21d381f5cb88f373f39ad9dae0896f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20No=C3=ABl?= Date: Tue, 10 Nov 2020 18:11:58 +0100 Subject: [PATCH] fix write access error of the update-notifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Noël --- .../strapi/lib/utils/update-notifier/index.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/strapi/lib/utils/update-notifier/index.js b/packages/strapi/lib/utils/update-notifier/index.js index 0a15ae83d3..3b38dc5699 100644 --- a/packages/strapi/lib/utils/update-notifier/index.js +++ b/packages/strapi/lib/utils/update-notifier/index.js @@ -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);