From 4c7199ded411c03bed39ba48adbc995fa7d4d2fb Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Mon, 2 Sep 2024 15:43:09 +0200 Subject: [PATCH] fix(cli-helpers): Don't add spaces around `=` for env vars (#11414) --- .changesets/11414.md | 3 +++ .../src/lib/__tests__/__snapshots__/project.test.ts.snap | 8 ++++---- packages/cli-helpers/src/lib/project.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 .changesets/11414.md diff --git a/.changesets/11414.md b/.changesets/11414.md new file mode 100644 index 000000000000..290760d0709f --- /dev/null +++ b/.changesets/11414.md @@ -0,0 +1,3 @@ +- fix(cli-helpers): Don't add spaces around `=` for env vars (#11414) by @Tobbe + +The `addEnvVar` helper function in `packages/cli-helpers` no longer adds spaces around `=` when setting environment variables. diff --git a/packages/cli-helpers/src/lib/__tests__/__snapshots__/project.test.ts.snap b/packages/cli-helpers/src/lib/__tests__/__snapshots__/project.test.ts.snap index 6b777b615443..b30b3f5b588b 100644 --- a/packages/cli-helpers/src/lib/__tests__/__snapshots__/project.test.ts.snap +++ b/packages/cli-helpers/src/lib/__tests__/__snapshots__/project.test.ts.snap @@ -6,7 +6,7 @@ exports[`addEnvVar > addEnvVar adds environment variables as part of a setup tas # Note: The existing environment variable EXISTING_VAR was not overwritten. Uncomment to use its new value. # Updated existing variable Comment -# EXISTING_VAR = new_value +# EXISTING_VAR=new_value " `; @@ -15,7 +15,7 @@ exports[`addEnvVar > addEnvVar adds environment variables as part of a setup tas # CommentedVar = 123 # New Variable Comment -NEW_VAR = new_value +NEW_VAR=new_value " `; @@ -24,7 +24,7 @@ exports[`addEnvVar > addEnvVar adds environment variables as part of a setup tas # CommentedVar = 123 # New Variable Comment -NEW_VAR = new_value +NEW_VAR=new_value " `; @@ -34,7 +34,7 @@ exports[`addEnvVar > addEnvVar adds environment variables as part of a setup tas # Note: The existing environment variable EXISTING_VAR was not overwritten. Uncomment to use its new value. # New Variable Comment -# EXISTING_VAR = new_value +# EXISTING_VAR=new_value " `; diff --git a/packages/cli-helpers/src/lib/project.ts b/packages/cli-helpers/src/lib/project.ts index afb44c62ef69..e57f51c0df02 100644 --- a/packages/cli-helpers/src/lib/project.ts +++ b/packages/cli-helpers/src/lib/project.ts @@ -126,7 +126,7 @@ export const addEnvVar = (name: string, value: string, comment: string) => { let envFile = '' const newEnvironmentVariable = [ comment && `# ${comment}`, - `${name} = ${value}`, + `${name}=${value}`, '', ] .flat() @@ -144,7 +144,7 @@ export const addEnvVar = (name: string, value: string, comment: string) => { const p = [ `# Note: The existing environment variable ${name} was not overwritten. Uncomment to use its new value.`, comment && `# ${comment}`, - `# ${name} = ${value}`, + `# ${name}=${value}`, '', ] .flat()