@@ -11,9 +11,9 @@ const path = require("path");
1111
1212function replace ( tsconfig , dist , mode ) {
1313 // Read tsconfig file.
14- const tsconfigPath = path . join ( __dirname , '..' , tsconfig ) ;
14+ const tsconfigPath = path . join ( __dirname , ".." , tsconfig ) ;
1515 console . log ( `\n using ${ tsconfigPath } ` ) ;
16- let data = JSON . parse ( fs . readFileSync ( path . join ( __dirname , '..' , tsconfig ) , "utf8" ) ) ;
16+ let data = JSON . parse ( fs . readFileSync ( path . join ( __dirname , ".." , tsconfig ) , "utf8" ) ) ;
1717 let a = data . compilerOptions . paths ;
1818 let keys = Object . keys ( a ) ;
1919
@@ -29,13 +29,13 @@ function replace(tsconfig, dist, mode) {
2929 let fileData = fs . readFileSync ( file , "utf8" ) ;
3030 for ( let key of keys ) {
3131 let value = a [ key ] [ 1 ] ?? a [ key ] [ 0 ] ;
32-
32+
3333 const absoluteIncludePath = path . resolve ( path . dirname ( tsconfigPath ) , value ) ;
3434 if ( mode == "resolve" && fs . existsSync ( absoluteIncludePath ) ) {
3535 const absoluteFilePath = path . resolve ( path . dirname ( file ) ) ;
3636 console . log ( `\t calculating path from ${ absoluteFilePath } to ${ absoluteIncludePath } ` ) ;
3737 // replace `\` with `/` to convert windows paths to node compatible imports
38- value = path . relative ( absoluteFilePath , absoluteIncludePath ) . replace ( / \\ / g, '/' ) ;
38+ value = path . relative ( absoluteFilePath , absoluteIncludePath ) . replace ( / \\ / g, "/" ) ;
3939 }
4040
4141 console . log ( `\t replace ${ key } with ${ value } ` ) ;
@@ -46,9 +46,10 @@ function replace(tsconfig, dist, mode) {
4646}
4747
4848const readdirSync = ( p , a = [ ] ) => {
49- if ( fs . statSync ( p ) . isDirectory ( ) )
50- fs . readdirSync ( p ) . map ( f => readdirSync ( a [ a . push ( path . join ( p , f ) ) - 1 ] , a ) )
51- return a
52- }
49+ if ( fs . statSync ( p ) . isDirectory ( ) ) {
50+ fs . readdirSync ( p ) . map ( f => readdirSync ( a [ a . push ( path . join ( p , f ) ) - 1 ] , a ) ) ;
51+ }
52+ return a ;
53+ } ;
5354
54- replace ( process . argv [ 2 ] , process . argv [ 3 ] , process . argv [ 4 ] ) ;
55+ replace ( process . argv [ 2 ] , process . argv [ 3 ] , process . argv [ 4 ] ) ;
0 commit comments