diff --git a/src/utils/index.ts b/src/utils/index.ts index 1b8280a..5197a9a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -8,6 +8,10 @@ export const cleanEmptyString = (value: string) => { return value === '""' ? '' : value; }; +export const cleanKey = (key: string) => { + return key?.replace('export', ''); +}; + export const parseLineAsKeyValue = ( line: string ): [string, string | number] => { @@ -17,7 +21,7 @@ export const parseLineAsKeyValue = ( .filter(Boolean) .map(p => p.replace(/\s+/g, '')) || []; - return [key, !isNaN(+value) ? +value : cleanEmptyString(value)]; + return [cleanKey(key), !isNaN(+value) ? +value : cleanEmptyString(value)]; }; export const cleanValue = (value: string | number) => { diff --git a/test/fixtures/simple.env b/test/fixtures/simple.env index 67ec1b9..dbc984f 100644 --- a/test/fixtures/simple.env +++ b/test/fixtures/simple.env @@ -5,3 +5,4 @@ OTHER_VAR= PREFILLED_VAR=42 BADLY_SPACED_VAR = here EMPTY_STRING="" +export EXPORTED_VAR=3 \ No newline at end of file diff --git a/test/fixtures/simple.ts b/test/fixtures/simple.ts index b7c662e..a3f60f4 100644 --- a/test/fixtures/simple.ts +++ b/test/fixtures/simple.ts @@ -4,4 +4,5 @@ export const constants = { PREFILLED_VAR: 42, BADLY_SPACED_VAR: 'here', EMPTY_STRING: '', + EXPORTED_VAR: 3, }; diff --git a/test/get-env-vars.test.ts b/test/get-env-vars.test.ts index f0886c3..d6bce85 100644 --- a/test/get-env-vars.test.ts +++ b/test/get-env-vars.test.ts @@ -58,6 +58,7 @@ describe('[getEnvVars]', () => { BADLY_SPACED_VAR: 'here', PREFILLED_VAR: 42, EMPTY_STRING: '', + EXPORTED_VAR: 3, }); }); });