From 59524cb4a81e9753a3d90da68612d648afcee68b Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Tue, 20 Dec 2022 12:32:49 -0500 Subject: [PATCH] [Webpack] Compilation error fix --- npm-postinstall.js | 23 ++++++++++++++++++----- webpack.config.js | 11 ++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/npm-postinstall.js b/npm-postinstall.js index 762732b4341..7c561ed1618 100644 --- a/npm-postinstall.js +++ b/npm-postinstall.js @@ -75,8 +75,19 @@ const getConfig = cp.spawn('php', [ 'useEEGBrowserVisualizationComponents', ], {}); +let EEGVisEnabled = false; getConfig.stdout.on('data', (data) => { - const EEGVisEnabled = JSON.parse(data); + try { + EEGVisEnabled = JSON.parse(data); + } catch (e) { + console.warn( + '\x1b[33m', + 'WARNING: Unable to fetch DB config', + 'useEEGBrowserVisualizationComponents', + '\x1b[0m', + ); + } + if (EEGVisEnabled === 'true') { console.info('\n ----- \n >> ' + 'EEG Browser visualization components enabled ' @@ -99,10 +110,12 @@ getConfig.stdout.on('data', (data) => { ); protoc.on('error', (error) => { - console.error('ERROR: ' - + 'Make sure that protoc ' - + '(https://github.com/protocolbuffers/protobuf/releases/) ' - + 'is installed on your system ' + console.error( + '\x1b[31m', + 'ERROR: Make sure that protoc', + '(https://github.com/protocolbuffers/protobuf/releases/)', + 'is installed on your system', + '\x1b[0m', ); console.error(error); }); diff --git a/webpack.config.js b/webpack.config.js index 1826f430084..5ab34393d40 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -76,7 +76,16 @@ if ('EEG_VIS_ENABLED' in process.env) { 'useEEGBrowserVisualizationComponents', ], {}); - EEGVisEnabled = JSON.parse(getConfig.stdout); + try { + EEGVisEnabled = JSON.parse(getConfig.stdout); + } catch (e) { + console.warn( + '\x1b[33m', + 'WARNING: Unable to fetch DB config', + 'useEEGBrowserVisualizationComponents', + '\x1b[0m', + ); + } } modulePlugins.push(