Skip to content

Commit

Permalink
[Webpack] Compilation error fix (#8293)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laemtl authored Dec 20, 2022
1 parent d504913 commit 4aaf5eb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
23 changes: 18 additions & 5 deletions npm-postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -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);
});
Expand Down
11 changes: 10 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4aaf5eb

Please # to comment.