soapbox/src/custom.ts

15 wiersze
468 B
TypeScript
Czysty Zwykły widok Historia

2022-03-04 05:38:59 +00:00
/**
* Functions for dealing with custom build configuration.
*/
2022-11-15 20:48:54 +00:00
import * as BuildConfig from 'soapbox/build-config';
2022-03-04 05:38:59 +00:00
/** Require a custom JSON file if it exists */
export const custom = (filename: string, fallback: any = {}): any => {
if (BuildConfig.NODE_ENV === 'test') return fallback;
2022-03-21 18:09:01 +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
};