Skip to content

Commit

Permalink
fix: remove export from variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtrom committed Oct 4, 2022
1 parent f269a5e commit 99e7d47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] => {
Expand All @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/simple.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ OTHER_VAR=
PREFILLED_VAR=42
BADLY_SPACED_VAR = here
EMPTY_STRING=""
export EXPORTED_VAR=3
1 change: 1 addition & 0 deletions test/fixtures/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export const constants = {
PREFILLED_VAR: 42,
BADLY_SPACED_VAR: 'here',
EMPTY_STRING: '',
EXPORTED_VAR: 3,
};
1 change: 1 addition & 0 deletions test/get-env-vars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('[getEnvVars]', () => {
BADLY_SPACED_VAR: 'here',
PREFILLED_VAR: 42,
EMPTY_STRING: '',
EXPORTED_VAR: 3,
});
});
});

0 comments on commit 99e7d47

Please sign in to comment.