Skip to content

Commit

Permalink
Merge pull request #85 from stuartleeks/sl/env-subst-casing
Browse files Browse the repository at this point in the history
Make env var substitution not case-sensitive
  • Loading branch information
stuartleeks authored Jul 7, 2021
2 parents 0c7bc42 + 99cdf56 commit b0bf285
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion azdo-task/DevContainerBuildRun/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion azdo-task/DevContainerBuildRun/dist/index.js.map

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions common/__tests__/envvars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ describe('substituteValues', () => {
expect(result).toBe('TEST_ENV1: TestEnvValue1, TEST_ENV2: TestEnvValue2')
})

test("Handles 'Env' substitution placeholders", async () => {
process.env.TEST_ENV1 = 'TestEnvValue1'
process.env.TEST_ENV2 = 'TestEnvValue2'
const input = 'TEST_ENV1: ${Env:TEST_ENV1}, TEST_ENV2: ${Env:TEST_ENV2}'
const result = await substituteValues(input)
expect(result).toBe('TEST_ENV1: TestEnvValue1, TEST_ENV2: TestEnvValue2')
})

test("ignores substitution placeholders that it doesn't understand", async () => {
const input = 'TEST_ENV: ${nothingToSee:TEST_ENV}'
const result = await substituteValues(input)
Expand Down
2 changes: 1 addition & 1 deletion common/src/envvars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function getSubstitutionValue(regexMatch: string, placeholder: string): string {
if (parts.length === 2) {
const type = parts[0]
const key = parts[1]
switch (type) {
switch (type.toLowerCase()) {
case 'env':
case 'localenv':
return process.env[key] ?? ''
Expand Down
2 changes: 1 addition & 1 deletion common_lib/envvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getSubstitutionValue(regexMatch, placeholder) {
if (parts.length === 2) {
const type = parts[0];
const key = parts[1];
switch (type) {
switch (type.toLowerCase()) {
case 'env':
case 'localenv':
return (_a = process.env[key]) !== null && _a !== void 0 ? _a : '';
Expand Down
2 changes: 1 addition & 1 deletion github-action/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion github-action/dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit b0bf285

Please sign in to comment.