File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { readFileSync } from "fs" ;
2
2
import path from "path" ;
3
- import { fileURLToPath } from "url" ;
4
-
5
- //Node.js 10 supports ECMAScript modules, where __dirname and __filename are no longer available.
6
- //https://stackoverflow.com/a/50053801/12988588
7
- //https://stackoverflow.com/a/55859500/12988588
8
- const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
3
+ import { getDirname } from "../utils" ;
9
4
5
+ const __dirname = getDirname ( import . meta. url )
10
6
const configFilePath = path . resolve ( __dirname , "../.env.json" ) ;
11
7
const configDataRaw = readFileSync ( configFilePath ) ;
12
8
const config = JSON . parse ( configDataRaw ) ;
Original file line number Diff line number Diff line change
1
+ import path from "path" ;
2
+ import { fileURLToPath } from "url" ;
3
+
4
+ //Node.js 10 supports ECMAScript modules, where __dirname and __filename are no longer available.
5
+ //https://stackoverflow.com/a/50053801/12988588
6
+ //https://stackoverflow.com/a/55859500/12988588
7
+ export const getDirname = ( filepath ) => {
8
+ return path . dirname ( fileURLToPath ( import . meta. url ) ) ;
9
+ }
10
+
You can’t perform that action at this time.
0 commit comments