@@ -34,6 +34,10 @@ class GraphqlStats extends Command {
3434 description : "Directories to ignore under src" ,
3535 multiple : true
3636 } ) ,
37+ port : flags . integer ( {
38+ description : "Port to run the report server on" ,
39+ default : 3001
40+ } ) ,
3741 quiet : flags . boolean ( {
3842 description : "No output to stdout" ,
3943 default : false
@@ -58,7 +62,7 @@ class GraphqlStats extends Command {
5862 async run ( ) {
5963 const { args, flags } = this . parse ( GraphqlStats ) ;
6064 const { schema, sourceDir } = args ;
61- const { json, exclude, quiet } = flags ;
65+ const { json, exclude, port , quiet } = flags ;
6266 const renderer = quiet ? "silent" : "default" ;
6367
6468 const analyzeFilesTask = {
@@ -85,9 +89,9 @@ class GraphqlStats extends Command {
8589 [
8690 analyzeFilesTask ,
8791 {
88- title : " Starting server at http://localhost:3001" ,
92+ title : ` Starting server at http://localhost:${ port } ` ,
8993 task : ( { report } : { report : Report } ) => {
90- startServer ( report ) ;
94+ startServer ( report , port ) ;
9195 }
9296 }
9397 ] ,
@@ -181,8 +185,7 @@ function writeJSON(report: Report): Promise<void> {
181185 ) ;
182186}
183187
184- function startServer ( report : Report ) : void {
185- const port = 3001 ;
188+ function startServer ( report : Report , port : number ) : void {
186189 createServer ( report ) . listen ( port , async ( ) => {
187190 // tslint:disable-next-line:no-http-string
188191 await open ( `http://localhost:${ port } ` ) ;
0 commit comments