Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid app crashes if /customization/html/details folder is missing #996

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion frontend/src/services/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ const fs = require('fs');
const deepmerge = require('deepmerge');
const { getLocales } = require('./getLocales');

function isPathExists(path) {
try {
fs.accessSync(path, fs.R_OK);
return true;
} catch (err) {
return false;
}
}

function getFiles(dir, files = []) {
if (!isPathExists(dir)) {
return files;
}
const fileList = fs.readdirSync(dir);
for (const file of fileList) {
const name = `${dir}/${file}`;
Expand All @@ -16,7 +28,7 @@ function getFiles(dir, files = []) {
}

const getContent = (path, parse) => {
if (fs.existsSync(path)) {
if (isPathExists(path)) {
const content = fs.readFileSync(path).toString();
return parse ? JSON.parse(content) : content;
}
Expand Down
Loading