Skip to content

Commit

Permalink
Fix bug introduced in #26
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Aug 19, 2024
1 parent f48c199 commit 3c790c0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/vite-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,21 @@ export function viteEnvs(params?: {
``,
...Object.entries(buildTimeMergedEnv)
.map(([name, value]) => {
const valueB64 = Buffer.from(
`${singularString2}${JSON.stringify(value)}\n`,
"utf8"
).toString("base64");
const [valueB64, valueB64_prefixed] = ([false, true] as const).map(
doUsePrefix =>
Buffer.from(
`${
doUsePrefix
? `${singularString2}${JSON.stringify(value)}`
: `${value}`
}\n`,
"utf8"
).toString("base64")
);

if (!(name in declaredEnv)) {
return [
`${name}_base64="${valueB64}"`,
`${name}_base64="${valueB64_prefixed}"`,
`${name}=$(echo "${valueB64}" | base64 -d)`
];
}
Expand All @@ -655,7 +662,7 @@ export function viteEnvs(params?: {
`if printenv ${name} &> /dev/null; then`,
` ${name}_base64=$(printenv ${name} | base64)`,
`else`,
` ${name}_base64="${valueB64}"`,
` ${name}_base64="${valueB64_prefixed}"`,
`fi`,
`${name}=\${${name}:-$(echo "${valueB64}" | base64 -d)}`
];
Expand Down

0 comments on commit 3c790c0

Please sign in to comment.