-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
201 additions
and
210 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const TEMPLATE_EXT = '.pug' | ||
|
||
export const renderTemplate = ( | ||
(renderPug, readFile) => ( | ||
(templateBasePath, data) => ( | ||
readFile(templateBasePath + TEMPLATE_EXT) | ||
.then((template) => renderPug(template, data)) | ||
) | ||
) | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
const DATA_FILE_PATH = 'data.json' | ||
const ENV_VAR_PLACEHOLDER_PATTERN = /^%(.+)%$/ | ||
|
||
function captureEnvVarName(value) { | ||
const captureEnvVarName = (value) => { | ||
const match = value.match?.(ENV_VAR_PLACEHOLDER_PATTERN) | ||
|
||
return match ? match[1] : null | ||
} | ||
|
||
export function parseProjectData(parseJSONFile, withSrcDir) { | ||
return withSrcDir((prefixWithSrcDir) => parseJSONFile(prefixWithSrcDir(DATA_FILE_PATH))) | ||
} | ||
export const parseProjectData = (parseJSONFile, withSrcDir) => ( | ||
withSrcDir((prefixWithSrcDir) => parseJSONFile(prefixWithSrcDir(DATA_FILE_PATH))) | ||
) | ||
|
||
export function mergeDataWithEnvVars( | ||
deepCloneObject, | ||
transformObjectValues, | ||
data, | ||
envVars, | ||
) { | ||
return transformObjectValues( | ||
deepCloneObject(data), | ||
(obj, key) => { | ||
const envVarName = captureEnvVarName(obj[key]) | ||
export const mergeDataWithEnvVars = ( | ||
(deepCloneObject, transformObjectValues) => ( | ||
(data, envVars) => ( | ||
transformObjectValues( | ||
deepCloneObject(data), | ||
(obj, key) => { | ||
const envVarName = captureEnvVarName(obj[key]) | ||
|
||
if (envVarName) { | ||
obj[key] = envVars[envVarName] ?? null | ||
} | ||
} | ||
if (envVarName) { | ||
obj[key] = envVars[envVarName] ?? null | ||
} | ||
}, | ||
) | ||
) | ||
) | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.