Skip to content

Commit

Permalink
feat: add additional info to event logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaxenormus committed Jul 5, 2023
1 parent 2cd8ad8 commit 83d5ccc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const validateEnv = (schema: z.AnyZodObject): Record<string, string | number> =>

export const withTypedEnv = (nextConfig: NextConfig, schema: z.ZodObject<ZodRawShape>) => {
wait("validating and generating environment files");
const timer = Date.now();
const validate = validateEnv(schema);
const { client, server } = Object.entries(validate).reduce(
({ client, server }, [key, value]) => {
Expand All @@ -66,6 +67,9 @@ export const withTypedEnv = (nextConfig: NextConfig, schema: z.ZodObject<ZodRawS
if (!existsSync(envDir)) mkdirSync(envDir, { recursive: true });
writeEnvFile(join(envDir, "env.client.ts"), renderEnvFile(client));
writeEnvFile(join(envDir, "env.server.ts"), renderEnvFile(server));
event("generated environment files");
const numOfEnvVars = Object.keys(validate).length;

const ms = Date.now() - timer;
event(`generated environment files in ${ms}ms (${numOfEnvVars} variables)`);
return nextConfig;
};

0 comments on commit 83d5ccc

Please sign in to comment.