From 4aaf5eb28789f457e098c53960fcd60b9fb0819f Mon Sep 17 00:00:00 2001 From: Laetitia Fesselier Date: Tue, 20 Dec 2022 14:35:43 -0500 Subject: [PATCH] [Webpack] Compilation error fix (#8293) Address an issue that prevents webpack and the post-install script to run when patch SQL/New_patches/2022-12-05-AddVizConfig.sql is not applied. Now the errors are caught and a warning is printed on the screen. --- 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(