From 68e8f1c9d697ca8ee2de272e895ac9fb634e5d86 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Sat, 8 Jan 2022 17:25:58 +0800 Subject: [PATCH] Core: Fix process.env assignment --- examples/react-ts/.env | 1 + examples/react-ts/src/button.stories.tsx | 7 +++++++ lib/core-common/src/utils/envs.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 examples/react-ts/.env diff --git a/examples/react-ts/.env b/examples/react-ts/.env new file mode 100644 index 000000000000..1566bb1d76a7 --- /dev/null +++ b/examples/react-ts/.env @@ -0,0 +1 @@ +FOO=bar \ No newline at end of file diff --git a/examples/react-ts/src/button.stories.tsx b/examples/react-ts/src/button.stories.tsx index b37bb8072345..db360ee35e09 100644 --- a/examples/react-ts/src/button.stories.tsx +++ b/examples/react-ts/src/button.stories.tsx @@ -27,6 +27,13 @@ export const StoryNoRender = { args: { label: 'magic!' }, }; +export const ProcessEnv = { + args: { label: process.env.FOO }, + play: () => { + process.env.BAZ = 'moo'; + }, +}; + export const StoryWithPlay = { args: { label: 'play' }, play: () => { diff --git a/lib/core-common/src/utils/envs.ts b/lib/core-common/src/utils/envs.ts index c5287b68de79..3ed12164f269 100644 --- a/lib/core-common/src/utils/envs.ts +++ b/lib/core-common/src/utils/envs.ts @@ -59,8 +59,12 @@ export const stringifyProcessEnvs = (raw: Record): Record