From 36f843c31dae9885370274521ff8526539eb77db Mon Sep 17 00:00:00 2001 From: brunosimon Date: Mon, 13 Nov 2017 13:50:59 +0100 Subject: [PATCH] :construction: Add support to server --- lib/index.js | 57 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/lib/index.js b/lib/index.js index b1f313a..ee9d6f5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -26,23 +26,27 @@ class App console.log() this.setConfig() - this.setSite( - () => - { - this.setSocket() - this.setProjects() - }, - () => - { - console.log('app'.green.bold + ' - ' + 'keppler seems to be running already'.cyan) - }, - () => - { - console.log('error'.red) - } - ) - this.setWatcher() + if(this.config.server && !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) + } + ) + } + + if(!this.config.server) + { + this.setWatcher() + } } /** @@ -108,6 +112,18 @@ class App default: 99999, 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 config.debug = args.debug @@ -118,6 +134,8 @@ class App config.test = args.test config.initialSend = args['initial-send'] config.maxFileSize = args['max-file-size'] + config.server = args.server + config.host = args.host if(config.name === '') { @@ -131,8 +149,13 @@ class App } } + if(config.host === '') + { + config.host = false + } + // 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 this.config = config