mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Add support for omit prefix
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import camelcase from 'camelcase';
|
||||
import env from '../env';
|
||||
|
||||
export function getConfigFromEnv(prefix: string) {
|
||||
export function getConfigFromEnv(prefix: string, omitPrefix?: string) {
|
||||
const config: any = {};
|
||||
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (key.toLowerCase().startsWith(prefix.toLowerCase()) === false) continue;
|
||||
if (omitPrefix && key.toLowerCase().startsWith(omitPrefix.toLowerCase()) === true) continue;
|
||||
config[camelcase(key.slice(prefix.length))] = value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user