open default browser when webserver has started

This commit is contained in:
Michael Bradley, Jr 2018-08-31 11:07:31 -05:00
parent f778dad589
commit 72943dc0e5

View File

@ -3,6 +3,7 @@ const fs = require('../../core/fs.js');
let http = require('http');
let serveStatic = require('serve-static');
const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host');
const opn = require('opn');
const utils = require('../../utils/utils.js');
require('http-shutdown').extend();
@ -10,6 +11,8 @@ require('ejs');
const embark_building_placeholder = require('../code_generator/code_templates/embark-building-placeholder.html.ejs');
let isFirstStart = true;
let opened = false;
class Server {
constructor(options) {
this.dist = options.dist || 'dist/';
@ -43,6 +46,10 @@ class Server {
" " +
("http://" + canonicalHost(this.hostname) +
":" + this.port).bold.underline.green, this.port);
if (!opened) {
opn(`http://${canonicalHost(this.hostname)}:${this.port}`);
opened = true;
}
});
}