Skip to content

Commit

Permalink
[ci] yarn format
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored and actions-user committed Feb 18, 2022
1 parent 39cbe50 commit aaa61ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/env-vars/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly DB_PASSWORD: string;
readonly DB_PASSWORD: string;
readonly PUBLIC_SOME_KEY: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv
readonly env: ImportMetaEnv;
}
2 changes: 1 addition & 1 deletion examples/env-vars/src/scripts/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

// PUBLIC_SOME_KEY is available everywhere
console.log({ SSR, PUBLIC_SOME_KEY });
})()
})();
8 changes: 4 additions & 4 deletions packages/astro/src/vite-plugin-env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function getPrivateEnv(viteConfig: vite.ResolvedConfig, astroConfig: AstroConfig
envPrefixes = Array.isArray(viteConfig.envPrefix) ? viteConfig.envPrefix : [viteConfig.envPrefix];
}
const fullEnv = loadEnv(viteConfig.mode, viteConfig.envDir ?? fileURLToPath(astroConfig.projectRoot), '');
const privateKeys = Object.keys(fullEnv).filter(key => {
const privateKeys = Object.keys(fullEnv).filter((key) => {
// don't expose any variables also on `process.env`
// note: this filters out `CLI_ARGS=1` passed to node!
if (typeof process.env[key] !== 'undefined') return false;
Expand All @@ -26,16 +26,16 @@ function getPrivateEnv(viteConfig: vite.ResolvedConfig, astroConfig: AstroConfig

// Otherwise, this is a private variable defined in an `.env` file
return true;
})
});
if (privateKeys.length === 0) {
return null;
}
return Object.fromEntries(privateKeys.map(key => [key, fullEnv[key]]));
return Object.fromEntries(privateKeys.map((key) => [key, fullEnv[key]]));
}

function referencesPrivateKey(source: string, privateEnv: Record<string, any>) {
for (const key of Object.keys(privateEnv)) {
if (source.includes(key)) return true;
if (source.includes(key)) return true;
}
return false;
}
Expand Down

0 comments on commit aaa61ff

Please sign in to comment.