File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ export class Config {
25
25
return Config . configuration . get ( val ) as T ;
26
26
}
27
27
28
+ private static setSettings ( key : string , val : number , isGlobal : boolean = false ) : Thenable < void > {
29
+ return Config . configuration . update ( key , val , isGlobal ) ;
30
+ }
31
+
28
32
public static get getHost ( ) : string {
29
33
return Config . getSettings < string > ( 'host' ) ;
30
34
}
@@ -37,6 +41,10 @@ export class Config {
37
41
return Config . getSettings < number > ( 'port' ) ;
38
42
}
39
43
44
+ public static setPort ( port : number ) : Thenable < void > {
45
+ return Config . setSettings ( 'port' , port ) ;
46
+ }
47
+
40
48
public static get getRoot ( ) : string {
41
49
return Config . getSettings < string > ( 'root' ) ;
42
50
}
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ export class AppModel implements IAppModel {
83
83
this . tagMissedCallback ( ) ;
84
84
} ) ;
85
85
86
- LiveServerHelper . StartServer ( params , ( serverInstance ) => {
86
+ LiveServerHelper . StartServer ( params , async ( serverInstance ) => {
87
87
if ( serverInstance && serverInstance . address ) {
88
88
this . LiveServerInstance = serverInstance ;
89
89
this . runningPort = serverInstance . address ( ) . port ;
@@ -100,10 +100,13 @@ export class AppModel implements IAppModel {
100
100
}
101
101
}
102
102
else {
103
- if ( ! serverInstance . errorMsg )
104
- this . showPopUpMsg ( `Error on port ${ Config . getPort } . Please try to change the port through settings or report on GitHub.` , true ) ;
105
- else
103
+ if ( ! serverInstance . errorMsg ) {
104
+ await Config . setPort ( Config . getPort + 1 ) ; // + 1 will be fine
105
+ this . showPopUpMsg ( `The default port : ${ Config . getPort - 1 } is currently taken, changing port to : ${ Config . getPort } .` ) ;
106
+ this . Golive ( pathUri ) ;
107
+ } else {
106
108
this . showPopUpMsg ( `Something is went wrong! Please check into Developer Console or report on GitHub.` , true ) ;
109
+ }
107
110
this . IsServerRunning = true ; // to revert status - cheat :p
108
111
this . ToggleStatusBar ( ) ; // reverted
109
112
}
You can’t perform that action at this time.
0 commit comments