File tree Expand file tree Collapse file tree 5 files changed +20
-5
lines changed
Expand file tree Collapse file tree 5 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 11/* Generated by main-file-generator */
2- module . exports . default = require ( '.. /build.js' ) . Default ;
2+ module . exports . default = require ( './build.js' ) . Default ;
Original file line number Diff line number Diff line change 11/* Generated by main-file-generator */
2- module . exports . default = require ( '.. /build.js' ) . World ;
2+ module . exports . default = require ( './build.js' ) . World ;
Original file line number Diff line number Diff line change 1+ /* */
2+ module . exports = require ( './dist/generator' ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " dts-bundle-proxyjs" ,
3- "version" : " 0.1.1 " ,
3+ "version" : " 0.2.0 " ,
44 "description" : " Generates JS proxies from bundled dts." ,
55 "main" : " index.js" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ export default class Generator {
4343
4444 // Get `require` relative path.
4545 let requireFileFullPath = path . join ( process . cwd ( ) , this . config . proxyjs . requireFile ) ;
46- let requireFileRelativePath = path . relative ( fullFilePath , requireFileFullPath ) . split ( path . sep ) . join ( '/' ) ;
47-
46+ let requireFileRelativePath = this . getRelativePath ( fullFilePath , requireFileFullPath ) ;
47+
4848 console . log ( fullFilePath ) ;
4949 //Write to file
5050 let stream = fs . createWriteStream ( fullFilePath , { 'flags' : 'w' } ) ;
@@ -70,4 +70,17 @@ export default class Generator {
7070 let parts = string . split ( '/' ) ;
7171 return ( parts . length > 0 ) ? parts [ parts . length - 1 ] : '' ;
7272 }
73+
74+ private getRelativePath ( fromDir : string , toFilePath : string ) {
75+ let filePath = path . relative ( path . dirname ( fromDir ) , toFilePath ) ;
76+ if ( path . sep !== "/" ) {
77+ filePath = filePath . split ( path . sep ) . join ( '/' ) ;
78+ }
79+
80+ if ( filePath . indexOf ( '/' ) === - 1 ) {
81+ filePath = './' + filePath ;
82+ }
83+
84+ return filePath ;
85+ }
7386}
You can’t perform that action at this time.
0 commit comments