[ci] yarn format
This commit is contained in:
parent
39cbe50085
commit
aaa61ff254
3 changed files with 7 additions and 7 deletions
4
examples/env-vars/src/env.d.ts
vendored
4
examples/env-vars/src/env.d.ts
vendored
|
@ -1,10 +1,10 @@
|
||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly DB_PASSWORD: string;
|
readonly DB_PASSWORD: string;
|
||||||
readonly PUBLIC_SOME_KEY: string;
|
readonly PUBLIC_SOME_KEY: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ImportMeta {
|
interface ImportMeta {
|
||||||
readonly env: ImportMetaEnv
|
readonly env: ImportMetaEnv;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
|
|
||||||
// PUBLIC_SOME_KEY is available everywhere
|
// PUBLIC_SOME_KEY is available everywhere
|
||||||
console.log({ SSR, PUBLIC_SOME_KEY });
|
console.log({ SSR, PUBLIC_SOME_KEY });
|
||||||
})()
|
})();
|
||||||
|
|
|
@ -14,7 +14,7 @@ function getPrivateEnv(viteConfig: vite.ResolvedConfig, astroConfig: AstroConfig
|
||||||
envPrefixes = Array.isArray(viteConfig.envPrefix) ? viteConfig.envPrefix : [viteConfig.envPrefix];
|
envPrefixes = Array.isArray(viteConfig.envPrefix) ? viteConfig.envPrefix : [viteConfig.envPrefix];
|
||||||
}
|
}
|
||||||
const fullEnv = loadEnv(viteConfig.mode, viteConfig.envDir ?? fileURLToPath(astroConfig.projectRoot), '');
|
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`
|
// don't expose any variables also on `process.env`
|
||||||
// note: this filters out `CLI_ARGS=1` passed to node!
|
// note: this filters out `CLI_ARGS=1` passed to node!
|
||||||
if (typeof process.env[key] !== 'undefined') return false;
|
if (typeof process.env[key] !== 'undefined') return false;
|
||||||
|
@ -26,16 +26,16 @@ function getPrivateEnv(viteConfig: vite.ResolvedConfig, astroConfig: AstroConfig
|
||||||
|
|
||||||
// Otherwise, this is a private variable defined in an `.env` file
|
// Otherwise, this is a private variable defined in an `.env` file
|
||||||
return true;
|
return true;
|
||||||
})
|
});
|
||||||
if (privateKeys.length === 0) {
|
if (privateKeys.length === 0) {
|
||||||
return null;
|
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>) {
|
function referencesPrivateKey(source: string, privateEnv: Record<string, any>) {
|
||||||
for (const key of Object.keys(privateEnv)) {
|
for (const key of Object.keys(privateEnv)) {
|
||||||
if (source.includes(key)) return true;
|
if (source.includes(key)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue