Skip to content

Commit

Permalink
fix(template): __dirname is not defined in ES module scope
Browse files Browse the repository at this point in the history
  • Loading branch information
yzh990918 committed Mar 28, 2023
1 parent 604ca3b commit 225f1e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://www.mongodb.com/atlas/database
API_KEY=xxx
API_BASE_URL=xxx
DATASOURCE=xxx
DATABASE=xxx
COLLECTION=xxx
4 changes: 4 additions & 0 deletions packages/templates/src/enum.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

import path from 'path'
import { fileURLToPath } from 'url'
import dotenv from 'dotenv'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

dotenv.config({
path: path.resolve(__dirname, '../../../.env'),
})
Expand Down

0 comments on commit 225f1e3

Please sign in to comment.