File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " dequanto" ,
3
- "version" : " 0.1.30 " ,
3
+ "version" : " 0.1.31 " ,
4
4
"author" : {
5
5
"name" : " Alex Kit" ,
6
6
"email" : " alex.kit@atmajs.com"
Original file line number Diff line number Diff line change @@ -15,5 +15,18 @@ export namespace $dependency {
15
15
//#endif
16
16
}
17
17
18
+ export function dirname ( ) {
19
+ if ( typeof __dirname === 'undefined' ) {
20
+ return __dirname ;
21
+ }
22
+ //#if (CJS)
23
+ throw new Error ( '__dirname is not defined in CommonJS environment' ) ;
24
+ //#endif
25
+
26
+ //#if (ESM)
27
+ // @ts -ignore: Conditional import
28
+ return import . meta. dirname ;
29
+ //#endif
30
+ }
18
31
}
19
32
Original file line number Diff line number Diff line change 1
1
import { class_Uri } from 'atma-utils' ;
2
2
import { $config } from './$config' ;
3
3
import { env } from 'atma-io' ;
4
+ import { $dependency } from './$dependency' ;
4
5
5
6
export namespace $path {
6
7
let root : string = null ;
@@ -80,11 +81,12 @@ export namespace $path {
80
81
return class_Uri . combine ( 'file://' + cwd , base ) ;
81
82
}
82
83
83
- let uri = new class_Uri ( 'file://' + __dirname + '/' ) ;
84
+ let dirname = $dependency . dirname ( ) ;
85
+ let uri = new class_Uri ( 'file://' + dirname + '/' ) ;
84
86
while ( true ) {
85
87
let dir = getDirName ( uri . path ) ;
86
88
if ( ! dir || dir === '/' ) {
87
- throw new Error ( `Root path not resolved: ${ __dirname } ` ) ;
89
+ throw new Error ( `Root path not resolved: ${ dirname } ` ) ;
88
90
}
89
91
if ( dir === 'lib' || dir === 'src' ) {
90
92
uri = uri . cdUp ( ) ;
You can’t perform that action at this time.
0 commit comments