Skip to content

Commit

Permalink
feature: Change how env vars are processed
Browse files Browse the repository at this point in the history
  • Loading branch information
fabschurt committed Jun 30, 2023
1 parent ff5868d commit 623c0c3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ buildProject(
params['<src-dir>'],
params['<build-dir>'],
params['--lang'],
process.env,
)
2 changes: 1 addition & 1 deletion src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export function parseData(
parseDataFromJsonFile,
parseDataFromEnv,
parseTranslations,
envVars = [],
lang = null,
envVars = [],
) {
return Promise.all([
parseDataFromJsonFile(withSrcDir, ifPathExists, readFile, parseJson),
Expand Down
2 changes: 1 addition & 1 deletion src/data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const JSON_FILE_NAME = 'data.json'
const ENV_VAR_PREFIX = '_MG_'
const ENV_VAR_PREFIX = '__'

function normalizeEnvVarName(str) {
return (
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default async function buildProject(
srcDirPath,
buildDirPath,
lang = null,
envVars = {},
) {
await ifPathExists(buildDirPath, rmDir)

Expand All @@ -33,8 +34,8 @@ export default async function buildProject(
parseDataFromJsonFile,
parseDataFromEnv,
parseTranslations,
process.env,
lang,
envVars,
)

return Promise.all([
Expand Down
4 changes: 2 additions & 2 deletions tests/data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ describe('#src/data', () => {
parseDataFromEnv({
EDITOR: 'vim',
LANG: 'en_US.UTF-8',
_MG_SECRET_PHONE_NUMBER: '+33777777777',
__SECRET_PHONE_NUMBER: '+33777777777',
SHELL: '/bin/bash',
_MG_EMAIL_ADDRESS: '[email protected]',
__EMAIL_ADDRESS: '[email protected]',
}),
{
secret_phone_number: '+33777777777',
Expand Down

0 comments on commit 623c0c3

Please sign in to comment.