pleroma/packages/pl-fe/src/custom.ts

17 lines
479 B
TypeScript
Raw Normal View History

2022-03-03 21:38:59 -08:00
/**
* Functions for dealing with custom build configuration.
*/
import * as BuildConfig from 'pl-fe/build-config';
2022-03-03 21:38:59 -08:00
/** Require a custom JSON file if it exists */
const custom = (filename: string, fallback: any = {}): any => {
if (BuildConfig.NODE_ENV === 'test') return fallback;
2022-03-21 11:09:01 -07:00
const modules = import.meta.glob('../custom/*.json', { eager: true });
2023-09-13 10:04:17 -07:00
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
};
export { custom };