bigbuffet-rw/app/soapbox/custom.js

15 lines
432 B
JavaScript
Raw Normal View History

2022-03-03 21:38:59 -08:00
/**
* Functions for dealing with custom build configuration.
*/
2022-03-21 11:09:01 -07:00
import { NODE_ENV } from 'soapbox/build_config';
2022-03-03 21:38:59 -08:00
/** Require a custom JSON file if it exists */
export const custom = (filename, fallback = {}) => {
2022-03-21 11:09:01 -07:00
if (NODE_ENV === 'test') return fallback;
2022-03-03 21:38:59 -08:00
const context = require.context('custom', false, /\.json$/);
const path = `./${filename}.json`;
return context.keys().includes(path) ? context(path) : fallback;
};