🐛 Fix browser not opening when using --host parameter

This commit is contained in:
brunosimon
2017-12-24 13:06:04 +01:00
parent 773364824e
commit da39a3065f
3 changed files with 47 additions and 21 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class Chat
setSocket()
{
// Create a channel for this specific chjat
// Create a channel for this specific chat
this.chatSocket = this.config.socket.of('/project/' + this.slug + '/chat')
// Connection event
+45 -19
View File
@@ -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
+1 -1
View File
@@ -114,7 +114,7 @@ Arguments list
|parameter|`--server`|
|shortcut|`-s`|
|default value|*(bool)*`false`|
|description|Start keppler has a server<br>(if you want to run an online instance)|
|description|Start keppler server only<br>(if you want to run an online instance)|
|||
|---|---|