Load explorer env from repo root
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import "dotenv/config";
|
||||
import "@peya-explorer/shared/load-env";
|
||||
import { z } from "zod";
|
||||
|
||||
const envSchema = z.object({
|
||||
@@ -12,4 +12,3 @@ const envSchema = z.object({
|
||||
});
|
||||
|
||||
export const env = envSchema.parse(process.env);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "dotenv/config";
|
||||
import "@peya-explorer/shared/load-env";
|
||||
import { z } from "zod";
|
||||
|
||||
const envSchema = z.object({
|
||||
@@ -13,4 +13,3 @@ const envSchema = z.object({
|
||||
});
|
||||
|
||||
export const env = envSchema.parse(process.env);
|
||||
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./load-env": "./dist/load-env.js"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
packages/shared/src/load-env.ts
Normal file
9
packages/shared/src/load-env.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const repoRoot = path.resolve(__dirname, "../../../");
|
||||
|
||||
// Workspace commands run from apps/*, so load the root-level .env explicitly.
|
||||
dotenv.config({ path: path.join(repoRoot, ".env") });
|
||||
Reference in New Issue
Block a user