2022-03-03 21:38:59 -08:00
|
|
|
/**
|
|
|
|
* Functions for dealing with custom build configuration.
|
|
|
|
*/
|
2022-11-15 12:48:54 -08:00
|
|
|
import * as BuildConfig from 'soapbox/build-config';
|
2022-03-03 21:38:59 -08:00
|
|
|
|
|
|
|
/** Require a custom JSON file if it exists */
|
2022-04-12 13:23:18 -07:00
|
|
|
export const custom = (filename: string, fallback: any = {}): any => {
|
|
|
|
if (BuildConfig.NODE_ENV === 'test') return fallback;
|
2022-03-21 11:09:01 -07:00
|
|
|
|
2023-09-13 10:04:17 -07:00
|
|
|
const modules = import.meta.glob('../../custom/*.json', { eager: true });
|
|
|
|
const key = `../../custom/${filename}.json`;
|
2022-03-03 21:38:59 -08:00
|
|
|
|
2023-09-13 10:04:17 -07:00
|
|
|
return modules[key] ? modules[key] : fallback;
|
2022-03-03 21:38:59 -08:00
|
|
|
};
|