File tree 3 files changed +16
-2
lines changed
3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export interface ServeTaskOptions {
26
26
sslKey ?: string ;
27
27
sslCert ?: string ;
28
28
aot ?: boolean ;
29
+ open ?: boolean ;
29
30
}
30
31
31
32
const ServeCommand = Command . extend ( {
@@ -79,7 +80,13 @@ const ServeCommand = Command.extend({
79
80
{ name : 'ssl' , type : Boolean , default : false } ,
80
81
{ name : 'ssl-key' , type : String , default : 'ssl/server.key' } ,
81
82
{ name : 'ssl-cert' , type : String , default : 'ssl/server.crt' } ,
82
- { name : 'aot' , type : Boolean , default : false }
83
+ { name : 'aot' , type : Boolean , default : false } ,
84
+ {
85
+ name : 'open' ,
86
+ description : 'Opens the url in default browser' ,
87
+ type : Boolean ,
88
+ default : false
89
+ } ,
83
90
] ,
84
91
85
92
run : function ( commandOptions : ServeTaskOptions ) {
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import { NgCliWebpackConfig } from '../models/webpack-config';
11
11
import { ServeTaskOptions } from '../commands/serve' ;
12
12
import { CliConfig } from '../models/config' ;
13
13
import { oneLine } from 'common-tags' ;
14
+ import * as url from 'url' ;
15
+ const opn = require ( 'opn' ) ;
14
16
15
17
export default Task . extend ( {
16
18
run : function ( commandOptions : ServeTaskOptions ) {
@@ -78,6 +80,11 @@ export default Task.extend({
78
80
console . error ( err . stack || err ) ;
79
81
if ( err . details ) { console . error ( err . details ) ; }
80
82
reject ( err . details ) ;
83
+ } else {
84
+ const { open, host, port } = commandOptions ;
85
+ if ( open ) {
86
+ opn ( url . format ( { protocol : 'http' , hostname : host , port : port . toString ( ) } ) ) ;
87
+ }
81
88
}
82
89
} ) ;
83
90
} ) ;
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ github_pages_deploy_opts='--base-href --environment --gh-token --gh-username --m
13
13
help_opts=' --json --verbose -v'
14
14
init_opts=' --dry-run inline-style inline-template --link-cli --mobile --name --prefix --routing --skip-bower --skip-npm --source-dir --style --verbose -d -is -it -lc -n -p -sb -sd -sn -v'
15
15
new_opts=' --directory --dry-run inline-style inline-template --link-cli --mobile --prefix --routing --skip-bower --skip-git --skip-npm --source-dir --style --verbose -d -dir -is -it -lc -p -sb -sd -sg -sn -v'
16
- serve_opts=' --aot --environment --host --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --port --proxy-config --ssl --ssl-cert --ssl-key --target --watcher -H -e -lr -lrbu -lrh -lrp -p -pc -t -w'
16
+ serve_opts=' --aot --environment --host --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --open -- port --proxy-config --ssl --ssl-cert --ssl-key --target --watcher -H -e -lr -lrbu -lrh -lrp -p -pc -t -w'
17
17
set_opts=' --global -g'
18
18
test_opts=' --browsers --build --colors --log-level --port --reporters --watch -w'
19
19
version_opts=' --verbose'
You can’t perform that action at this time.
0 commit comments