🚧 Add support to server

This commit is contained in:
brunosimon
2017-11-13 13:50:59 +01:00
parent a1b80b9a98
commit 36f843c31d
+28 -5
View File
@@ -26,6 +26,9 @@ class App
console.log() console.log()
this.setConfig() this.setConfig()
if(this.config.server && !this.config.host)
{
this.setSite( this.setSite(
() => () =>
{ {
@@ -33,17 +36,18 @@ class App
this.setProjects() this.setProjects()
}, },
() => () =>
{
console.log('app'.green.bold + ' - ' + 'keppler seems to be running already'.cyan)
},
() =>
{ {
console.log('error'.red) console.log('error'.red)
console.log('app'.green.bold + ' - ' + 'keppler seems to be running already'.cyan)
} }
) )
}
if(!this.config.server)
{
this.setWatcher() this.setWatcher()
} }
}
/** /**
* Set config * Set config
@@ -108,6 +112,18 @@ class App
default: 99999, default: 99999,
type: 'number' type: 'number'
}) })
.option('server', {
alias: 's',
describe: 'Start keppler has server',
default: false,
type: 'boolean'
})
.option('host', {
alias: 'h',
describe: 'Host, in case it\'s not a local',
default: '',
type: 'string'
})
.argv .argv
config.debug = args.debug config.debug = args.debug
@@ -118,6 +134,8 @@ class App
config.test = args.test config.test = args.test
config.initialSend = args['initial-send'] config.initialSend = args['initial-send']
config.maxFileSize = args['max-file-size'] config.maxFileSize = args['max-file-size']
config.server = args.server
config.host = args.host
if(config.name === '') if(config.name === '')
{ {
@@ -131,8 +149,13 @@ class App
} }
} }
if(config.host === '')
{
config.host = false
}
// Custom // Custom
config.domain = `http://${ip.address()}${config.port !== 80 ? ':' + config.port : ''}` config.domain = `http://${config.host ? config.host : ip.address()}${config.port !== 80 ? ':' + config.port : ''}`
// Save // Save
this.config = config this.config = config