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