🐛 Fix browser not opening when using --host parameter
This commit is contained in:
+45
-19
@@ -28,21 +28,16 @@ class App
|
||||
this.setConfig()
|
||||
|
||||
// If host is not specified
|
||||
// Start the site
|
||||
// Start the server
|
||||
if(!this.config.host)
|
||||
{
|
||||
this.setSite(
|
||||
() =>
|
||||
{
|
||||
this.setSocket()
|
||||
this.setProjects()
|
||||
},
|
||||
() =>
|
||||
{
|
||||
console.log('error'.red)
|
||||
console.log('app'.green.bold + ' - ' + 'keppler seems to be running already'.cyan)
|
||||
}
|
||||
)
|
||||
this.setServer()
|
||||
}
|
||||
|
||||
// If host is specified, show URL open in browser
|
||||
if(this.config.host)
|
||||
{
|
||||
this.showUrlAndOpen()
|
||||
}
|
||||
|
||||
// If not started as a server
|
||||
@@ -175,6 +170,26 @@ class App
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set server
|
||||
* Insitantiate the site and when the site is ready, instantiate the socket connexion and projects
|
||||
*/
|
||||
setServer()
|
||||
{
|
||||
this.setSite(
|
||||
() =>
|
||||
{
|
||||
this.setSocket()
|
||||
this.setProjects()
|
||||
},
|
||||
() =>
|
||||
{
|
||||
console.log('error'.red)
|
||||
console.log('app'.green.bold + ' - ' + 'keppler seems to be running already'.cyan)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set site
|
||||
* Instantiate site
|
||||
@@ -224,13 +239,10 @@ class App
|
||||
console.log(util.inspect(project.files.describe(), { depth: null, colors: true }))
|
||||
}
|
||||
|
||||
// Open in browser
|
||||
const url = this.config.domain
|
||||
console.log('app'.green.bold + ' - ' + url.yellow)
|
||||
|
||||
if(this.config.open)
|
||||
// If not server, show URL open in browser
|
||||
if(!this.config.server)
|
||||
{
|
||||
opener(url)
|
||||
this.showUrlAndOpen()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -315,6 +327,20 @@ class App
|
||||
{
|
||||
this.watcher = new Watcher(this.config)
|
||||
}
|
||||
|
||||
/**
|
||||
* Show URL and open it if should
|
||||
*/
|
||||
showUrlAndOpen()
|
||||
{
|
||||
const url = this.config.domain
|
||||
console.log('app'.green.bold + ' - ' + url.yellow)
|
||||
|
||||
if(this.config.open)
|
||||
{
|
||||
opener(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = App
|
||||
|
||||
Reference in New Issue
Block a user