@@ -34,6 +34,7 @@ export namespace Application {
34
34
defaultAdditionalEntryName = 'Additional documentation' ,
35
35
defaultAdditionalEntryPath = 'additional-documentation' ,
36
36
defaultFolder = './documentation/' ,
37
+ defaultPort = 8080 ,
37
38
defaultTheme = 'gitbook' ;
38
39
39
40
program
@@ -49,6 +50,7 @@ export namespace Application {
49
50
//.option('-j, --includesName [name]', 'Name of item menu of externals markdown file')
50
51
. option ( '-t, --silent' , 'In silent mode, log messages aren\'t logged in the console' , false )
51
52
. option ( '-s, --serve' , 'Serve generated documentation (default http://localhost:8080/)' , false )
53
+ . option ( '-r, --port [port]' , 'Change default serving port' )
52
54
. option ( '-g, --hideGenerator' , 'Do not print the Compodoc link at the bottom of the page' , false )
53
55
. parse ( process . argv ) ;
54
56
@@ -74,6 +76,10 @@ export namespace Application {
74
76
$configuration . mainData . theme = defaultTheme ;
75
77
}
76
78
79
+ if ( program . port ) {
80
+ defaultPort = program . port ;
81
+ }
82
+
77
83
$configuration . mainData . documentationMainName = program . name ; //default commander value
78
84
79
85
$configuration . mainData . base = program . base ;
@@ -442,7 +448,7 @@ export namespace Application {
442
448
let finalTime = ( new Date ( ) - startTime ) / 1000 ;
443
449
logger . info ( 'Documentation generated in ' + defaultFolder + ' in ' + finalTime + ' seconds' ) ;
444
450
if ( program . serve ) {
445
- logger . info ( `Serving documentation from ${ defaultFolder } at http://127.0.0.1:8080 ` ) ;
451
+ logger . info ( `Serving documentation from ${ defaultFolder } at http://127.0.0.1:${ defaultPort } ` ) ;
446
452
runWebServer ( defaultFolder ) ;
447
453
}
448
454
}
@@ -464,7 +470,8 @@ export namespace Application {
464
470
root : folder ,
465
471
open : false ,
466
472
quiet : true ,
467
- logLevel : 0
473
+ logLevel : 0 ,
474
+ port : defaultPort
468
475
} ) ;
469
476
}
470
477
@@ -478,7 +485,7 @@ export namespace Application {
478
485
logger . fatal ( `${ program . output } folder doesn't exist` ) ;
479
486
process . exit ( 1 ) ;
480
487
} else {
481
- logger . info ( `Serving documentation from ${ program . output } at http://127.0.0.1:8080 ` ) ;
488
+ logger . info ( `Serving documentation from ${ program . output } at http://127.0.0.1:${ defaultPort } ` ) ;
482
489
runWebServer ( program . output ) ;
483
490
}
484
491
} else if ( program . serve && ! program . tsconfig && ! program . output ) {
@@ -487,7 +494,7 @@ export namespace Application {
487
494
logger . fatal ( 'Provide output generated folder with -d flag' ) ;
488
495
process . exit ( 1 ) ;
489
496
} else {
490
- logger . info ( `Serving documentation from ${ defaultFolder } at http://127.0.0.1:8080 ` ) ;
497
+ logger . info ( `Serving documentation from ${ defaultFolder } at http://127.0.0.1:${ defaultPort } ` ) ;
491
498
runWebServer ( defaultFolder ) ;
492
499
}
493
500
} else {
0 commit comments