custom: fix import leak

merge-requests/1073/head
Alex Gleason 2022-03-03 23:38:59 -06:00
rodzic afb7827f40
commit 8d64bf2697
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 14 dodań i 10 usunięć

Wyświetl plik

@ -0,0 +1,11 @@
/**
* Functions for dealing with custom build configuration.
*/
/** Require a custom JSON file if it exists */
export const custom = (filename, fallback = {}) => {
const context = require.context('custom', false, /\.json$/);
const path = `./${filename}.json`;
return context.keys().includes(path) ? context(path) : fallback;
};

Wyświetl plik

@ -4,19 +4,12 @@ import { createSelector } from 'reselect';
import gte from 'semver/functions/gte';
import lt from 'semver/functions/lt';
// FIXME: We have to use a dynamic import to trick Webpack into treating it as
// optional, but this causes custom locales to become part of the main chunk.
const importCustom = path => {
try {
return require(`custom/${path}.json`);
} catch(e) {
return {};
}
};
import { custom } from 'soapbox/custom';
// Import custom overrides, if exists
const overrides = importCustom('features');
const overrides = custom('features');
// Truthy array convenience function
const any = arr => arr.some(Boolean);
// For uglification