This repository was archived by the owner on Jun 8, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +28
-22
lines changed Expand file tree Collapse file tree 4 files changed +28
-22
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " mongoose-tsgen" ,
3
3
"description" : " A Typescript interface generator for Mongoose that works out of the box." ,
4
- "version" : " 9.0.0 " ,
4
+ "version" : " 9.0.1 " ,
5
5
"author" : " Francesco Virga @francescov1" ,
6
6
"bin" : {
7
7
"mtgen" : " ./bin/run"
21
21
"glob" : " ^7.1.6" ,
22
22
"lodash" : " ^4.17.20" ,
23
23
"mkdirp" : " ^1.0.4" ,
24
- "prettier" : " ^2.1.2 " ,
24
+ "prettier" : " ^2.5.1 " ,
25
25
"strip-json-comments" : " ^3.1.1" ,
26
26
"ts-morph" : " ^9.1.0" ,
27
27
"ts-node" : " ^9.1.1" ,
Original file line number Diff line number Diff line change @@ -372,15 +372,20 @@ export const registerUserTs = (basePath: string): (() => void) | null => {
372
372
373
373
// handle path aliases
374
374
const tsConfigString = fs . readFileSync ( foundPath , "utf8" ) ;
375
- const tsConfig = JSON . parse ( stripJsonComments ( tsConfigString ) ) ;
376
- if ( tsConfig ?. compilerOptions ?. paths ) {
377
- const cleanup = require ( "tsconfig-paths" ) . register ( {
378
- baseUrl : process . cwd ( ) ,
379
- paths : tsConfig . compilerOptions . paths
380
- } ) ;
381
-
382
- return cleanup ;
383
- }
384
375
385
- return null ;
376
+ try {
377
+ const tsConfig = JSON . parse ( stripJsonComments ( tsConfigString ) ) ;
378
+ if ( tsConfig ?. compilerOptions ?. paths ) {
379
+ const cleanup = require ( "tsconfig-paths" ) . register ( {
380
+ baseUrl : process . cwd ( ) ,
381
+ paths : tsConfig . compilerOptions . paths
382
+ } ) ;
383
+
384
+ return cleanup ;
385
+ }
386
+
387
+ return null ;
388
+ } catch {
389
+ throw new Error ( "Error parsing your tsconfig.json file, please ensure the format is valid" ) ;
390
+ }
386
391
} ;
Original file line number Diff line number Diff line change @@ -71,8 +71,8 @@ class MongooseTsgen extends Command {
71
71
72
72
// we cant set flags as `default` using the official oclif method since the defaults would overwrite flags provided in the config file.
73
73
// instead, well just set "output" and "project" as default manually if theyre still missing after merge with configFile.
74
- configFileFlags . output = configFileFlags . output ?? "./src/interfaces" ;
75
- configFileFlags . project = configFileFlags . project ?? "./" ;
74
+ configFileFlags . output = configFileFlags ? .output ?? "./src/interfaces" ;
75
+ configFileFlags . project = configFileFlags ? .project ?? "./" ;
76
76
77
77
return {
78
78
flags : {
@@ -136,12 +136,13 @@ class MongooseTsgen extends Command {
136
136
this . log ( `Writing interfaces to ${ genFilePath } ` ) ;
137
137
138
138
generator . saveFile ( { genFilePath, sourceFile } ) ;
139
+
139
140
if ( ! flags [ "no-format" ] ) await formatter . format ( [ genFilePath ] ) ;
140
141
this . log ( "Writing complete 🐒" ) ;
141
142
process . exit ( ) ;
142
143
}
143
144
} catch ( error ) {
144
- this . error ( error as Error ) ;
145
+ this . error ( error as Error , { exit : 1 } ) ;
145
146
}
146
147
}
147
148
}
You can’t perform that action at this time.
0 commit comments