mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-26 20:30:43 +00:00
open default browser when webserver has started
This commit is contained in:
parent
f778dad589
commit
72943dc0e5
@ -3,6 +3,7 @@ const fs = require('../../core/fs.js');
|
|||||||
let http = require('http');
|
let http = require('http');
|
||||||
let serveStatic = require('serve-static');
|
let serveStatic = require('serve-static');
|
||||||
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
|
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
|
||||||
|
const opn = require('opn');
|
||||||
const utils = require('../../utils/utils.js');
|
const utils = require('../../utils/utils.js');
|
||||||
require('http-shutdown').extend();
|
require('http-shutdown').extend();
|
||||||
|
|
||||||
@ -10,6 +11,8 @@ require('ejs');
|
|||||||
const embark_building_placeholder = require('../code_generator/code_templates/embark-building-placeholder.html.ejs');
|
const embark_building_placeholder = require('../code_generator/code_templates/embark-building-placeholder.html.ejs');
|
||||||
|
|
||||||
let isFirstStart = true;
|
let isFirstStart = true;
|
||||||
|
let opened = false;
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.dist = options.dist || 'dist/';
|
this.dist = options.dist || 'dist/';
|
||||||
@ -43,6 +46,10 @@ class Server {
|
|||||||
" " +
|
" " +
|
||||||
("http://" + canonicalHost(this.hostname) +
|
("http://" + canonicalHost(this.hostname) +
|
||||||
":" + this.port).bold.underline.green, this.port);
|
":" + this.port).bold.underline.green, this.port);
|
||||||
|
if (!opened) {
|
||||||
|
opn(`http://${canonicalHost(this.hostname)}:${this.port}`);
|
||||||
|
opened = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user