File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,13 +10,26 @@ export default class CommandManager {
1010 // Store the visual name in the node environment
1111 env . VISUAL_NAME = name ;
1212
13+ const visualRoot = ngJson . projects [ name ] . root ;
14+ const pkgJson = readJsonFromVisual ( `${ visualRoot } /package.json` ) ;
15+
16+ // Get the port from the server field in the package.json
17+ let port = '' ;
18+ try {
19+ port = pkgJson . server ? new URL ( pkgJson . server ) . port : '' ;
20+ } catch ( e ) {
21+ console . error ( e ) ;
22+ }
23+
24+ const opts = Object . assign ( { port } , options ) ;
25+
1326 // --port=4201 => { port: '4201' } => ['--port=4201']
1427 // -p=4201 => { port: '=4201' } => ['--port=4201']
15- const optsArr = Object . keys ( options ) . map ( key => {
16- if ( options [ key ] . startsWith ( '=' ) ) {
17- return `--${ key } ${ options [ key ] } ` ;
28+ const optsArr = Object . keys ( opts ) . map ( key => {
29+ if ( opts [ key ] . startsWith ( '=' ) ) {
30+ return `--${ key } ${ opts [ key ] } ` ;
1831 }
19- return `--${ key } =${ options [ key ] } ` ;
32+ return `--${ key } =${ opts [ key ] } ` ;
2033 } ) ;
2134
2235 const ng = spawn ( 'ng' , [ 'serve' , name , ...optsArr ] ) ;
You can’t perform that action at this time.
0 commit comments