fix: support special characters in default expansion#74
Merged
motdotla merged 4 commits intomotdotla:masterfrom Dec 16, 2022
Merged
fix: support special characters in default expansion#74motdotla merged 4 commits intomotdotla:masterfrom
motdotla merged 4 commits intomotdotla:masterfrom
Conversation
FezVrasta
commented
Mar 29, 2022
| "readmeFilename": "README.md", | ||
| "license": "BSD-2-Clause", | ||
| "devDependencies": { | ||
| "@hapi/lab": "^24.5.1", |
Contributor
Author
There was a problem hiding this comment.
Had to upgrade this because the espree used by 14.x didn't support the regex lookbehind.
FezVrasta
commented
Mar 29, 2022
Comment on lines
+14
to
+16
| DEFINED_EXPAND_WITH_DEFAULT_WITH_SPECIAL_CHARACTERS=${MACHINE:-/default/path:with/colon} | ||
| UNDEFINED_EXPAND_WITH_DEFAULT_WITH_SPECIAL_CHARACTERS=${UNDEFINED_ENV_KEY:-/default/path:with/colon} | ||
| UNDEFINED_EXPAND_WITH_DEFAULT_WITH_SPECIAL_CHARACTERS_NESTED=${UNDEFINED_ENV_KEY:-${UNDEFINED_ENV_KEY_2:-/default/path:with/colon}} |
Contributor
Author
There was a problem hiding this comment.
I updated the test cases to include a semicolon to ensure everything is working properly with it.
FezVrasta
commented
Mar 30, 2022
| return matches.length > 0 ? matches.slice(-1)[0].index : -1 | ||
| } | ||
|
|
||
| function _interpolate (envValue, environment, config) { |
Contributor
Author
There was a problem hiding this comment.
The function now works as follows:
- Find the right-most group of variables (it can be a single
$VARIABLEor a nested one (${VARIABLE:-${NESTED:-default}}); - Expand the inner-most variable;
- Repeat from point 1 until no more variables are found;
Example with { VAR1: "var1", VAR2: "var2", VAR3: undefined }
FOO=${VAR1}something${VAR2:-$VAR3:-default}FOO=${VAR1}something${VAR2:-default}FOO=${VAR1}somethingvar2FOO=var1somethingvar2
FezVrasta
commented
Mar 30, 2022
10 tasks
Contributor
Author
|
Could I get someone to review this please? Anything I can do to help? |
@vantreeseba confirmed the test case had a typo in it. motdotla#39 (comment)
Contributor
Author
|
Friendly ping @motdotla |
Contributor
Author
|
Hello? |
Contributor
Author
|
Any chance to have this PR reviewed? |
Contributor
Author
|
Hi? |
Contributor
Author
|
Henlo frien? |
fbnfgc
added a commit
to fbnfgc/serverless
that referenced
this pull request
Mar 14, 2023
medikoo
pushed a commit
to serverless/serverless
that referenced
this pull request
Mar 15, 2023
9 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #73 by rewriting the whole library to use a simpler approach to the problem.
I think the code should be more readable now, and support more use cases.