diff options
author | 2023-09-19 03:14:29 +0200 | |
---|---|---|
committer | 2023-09-18 18:14:29 -0700 | |
commit | 064721668740397763a2ab6b6293d5d34a7b14a8 (patch) | |
tree | 27a3f3277c70328382d772536864762ccb5e0f42 /test | |
parent | 6df837cff18882ae323d49e1a9def7fc6ab5a5b0 (diff) | |
download | bun-064721668740397763a2ab6b6293d5d34a7b14a8.tar.gz bun-064721668740397763a2ab6b6293d5d34a7b14a8.tar.zst bun-064721668740397763a2ab6b6293d5d34a7b14a8.zip |
fix: provide empty string to 0 length process environment variables (#5679)
* fix: provide empty string to len 0 process env vars
For process loaded env vars, its a bug to give them the literal value '""'
if the provided length is 0.
* fix: add test and remove unneeded branch
Removes the redundant branch for empty env vars and adds a test for the
process specific case.
* fix: remove empty_string_value
Removes the constant in favor of using the empty values or passing the
literal "".
* style: format env.test.ts
Diffstat (limited to 'test')
-rw-r--r-- | test/cli/run/env.test.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/cli/run/env.test.ts b/test/cli/run/env.test.ts index 3ed300477..1c2d51e8e 100644 --- a/test/cli/run/env.test.ts +++ b/test/cli/run/env.test.ts @@ -385,6 +385,16 @@ test(".env with zero length strings", () => { expect(stdout).toBe("||0|0"); }); +test("process with zero length environment variable", () => { + const dir = tempDirWithFiles("process-issue-zerolength", { + "index.ts": "console.log(`'${process.env.TEST_ENV_VAR}'`);", + }); + const { stdout } = bunRun(`${dir}/index.ts`, { + TEST_ENV_VAR: "", + }); + expect(stdout).toBe("''"); +}); + test(".env in a folder doesn't throw an error", () => { const dir = tempDirWithFiles("dotenv-issue-3670", { ".env": { |