File tree Expand file tree Collapse file tree 8 files changed +22
-16
lines changed
Expand file tree Collapse file tree 8 files changed +22
-16
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 55 "removeSource" : true ,
66 "proxyjs" : {
77 "default" : " Hello" ,
8- "generateDir " : " ./dist" ,
8+ "outDir " : " ./dist" ,
99 "requireFile" : " ./dist/build.js"
1010 }
1111}
Original file line number Diff line number Diff line change 11{
22 "name" : " example-lib" ,
3- "version" : " 1.0 .0" ,
3+ "version" : " 0.3 .0" ,
44 "main" : " ./dist/index.js" ,
55 "devDependencies" : {
66 "rollup" : " ^0.34.7" ,
Original file line number Diff line number Diff line change 11{
22 "name" : " dts-bundle-proxyjs" ,
3- "version" : " 0.2 .0" ,
3+ "version" : " 0.3 .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 @@ -13,15 +13,15 @@ export default yargs
1313 } )
1414 . option ( 'default' , {
1515 alias : 'd' ,
16- describe : 'Bundled default export.' ,
16+ describe : 'Bundled require default export.' ,
1717 type : 'string'
1818 } )
19- . option ( 'generatedir ' , {
20- alias : 'g ' ,
19+ . option ( 'outDir ' , {
20+ alias : 'o ' ,
2121 describe : 'Where generate JS files.' ,
2222 type : 'string'
2323 } )
24- . option ( 'requirefile ' , {
24+ . option ( 'requireFile ' , {
2525 alias : 'r' ,
2626 describe : 'Bundled JS main file.' ,
2727 type : 'string'
Original file line number Diff line number Diff line change @@ -39,9 +39,15 @@ class Cli {
3939
4040 private getConfig ( config : Contracts . Config , args : Contracts . Arguments ) {
4141 if ( args . default != null ) config . proxyjs . default = args . default ;
42- if ( args . generatedir != null ) config . proxyjs . generateDir = args . generatedir ;
43- if ( args . requirefile != null ) config . proxyjs . requireFile = args . requirefile ;
42+ if ( args . outDir != null ) config . proxyjs . outDir = args . outDir ;
43+ if ( args . requireFile != null ) config . proxyjs . requireFile = args . requireFile ;
4444 if ( config . baseDir == null ) config . baseDir = '' ;
45+ if ( config . proxyjs . outDir == null ) {
46+ this . throwError ( '[Error] In proxyjs config `outDir` is undefined.' ) ;
47+ }
48+ if ( config . proxyjs . requireFile == null ) {
49+ this . throwError ( '[Error] In proxyjs config `requireFile` is undefined.' ) ;
50+ }
4551 return config ;
4652 }
4753
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export interface Config {
44 out : string ;
55 proxyjs : {
66 default : string ;
7- generateDir : string ;
7+ outDir : string ;
88 requireFile : string ;
99 }
1010}
@@ -15,6 +15,6 @@ export interface Arguments {
1515 help : boolean ;
1616 version : boolean ;
1717 default : string ;
18- generatedir : string ;
19- requirefile : string ;
18+ outDir : string ;
19+ requireFile : string ;
2020}
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export default class Generator {
3737 console . info ( clc . yellow ( 'Generating files:' ) ) ;
3838 matches . forEach ( ( match : string ) => {
3939 let cleanedMatch = this . cleanModule ( match ) ;
40- let fullFilePath = path . join ( process . cwd ( ) , this . config . proxyjs . generateDir , `${ match } .js` ) ;
40+ let fullFilePath = path . join ( process . cwd ( ) , this . config . proxyjs . outDir , `${ match } .js` ) ;
4141 // Make sure that all folders are created.
4242 mkdirp . sync ( path . dirname ( fullFilePath ) ) ;
4343
@@ -61,7 +61,7 @@ export default class Generator {
6161
6262 private generateLine ( requirePath : string , moduleName : string ) {
6363 if ( this . config . proxyjs . default === moduleName ) {
64- moduleName = 'Default ' ;
64+ moduleName = 'default ' ;
6565 }
6666 return `module.exports.default = require('${ requirePath } ').${ moduleName } ;` ;
6767 }
@@ -77,7 +77,7 @@ export default class Generator {
7777 filePath = filePath . split ( path . sep ) . join ( '/' ) ;
7878 }
7979
80- if ( filePath . indexOf ( '/' ) === - 1 ) {
80+ if ( filePath . indexOf ( '.. /' ) !== 0 ) {
8181 filePath = './' + filePath ;
8282 }
8383
You can’t perform that action at this time.
0 commit comments