-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from chombium/node-lts-refactoring
Node v6.9.5 refactoring and new code formatting
- Loading branch information
Showing
21 changed files
with
1,386 additions
and
1,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ docs | |
mosquitto.db | ||
db/ | ||
|
||
.project | ||
.settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,102 @@ | ||
'use strict'; | ||
'use strict' | ||
/******************************************************************************* | ||
* Copyright (c) 2013-2014 Matteo Collina | ||
* Copyright (c) 2013-2017 Matteo Collina | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* Matteo Collina - initial API and implementation and/or initial documentation | ||
* Jovan Kostovski - added standard js for source code style checking | ||
*******************************************************************************/ | ||
|
||
var commander = require("commander"); | ||
var pkg = require("../package.json"); | ||
var path = require("path"); | ||
/** | ||
* CLI module | ||
* @description A module to hanlde the commandline and starting of Ponte | ||
* @module | ||
*/ | ||
var commander = require('commander') | ||
var pkg = require('../package.json') | ||
var path = require('path') | ||
|
||
module.exports = function(args, done) { | ||
module.exports = function (args, done) { | ||
args = args || [] | ||
|
||
args = args || []; | ||
|
||
var program = new commander.Command(); | ||
var server = null; | ||
var runned = false; | ||
var program = new commander.Command() | ||
|
||
program | ||
.version(pkg.version) | ||
.option("-m, --mqtt-port <n>", "the mqtt port to listen to", parseInt) | ||
.option("-p, --http-port <n>", "the http port to listen to", parseInt) | ||
.option("-a, --coap-port <n>", "the coap port to listen to", parseInt) | ||
.option("--host <host>", "the host to listen to") | ||
.option("--coap-host <host>", "the host to listen to for coap requests") | ||
.option("--mqtt-host <host>", "the host to listen to for mqtt requests") | ||
.option("--http-host <host>", "the host to listen to for http requests") | ||
.option("-d, --db <path>", "the path were to store the database") | ||
.option("-c, --config <c>", "the config file to use (override every other option)") | ||
.option("-v, --verbose", "set the bunyan log to INFO") | ||
.option("--very-verbose", "set the bunyan log to DEBUG"); | ||
|
||
program.parse(args); | ||
.option('-m, --mqtt-port <n>', 'the mqtt port to listen to', parseInt) | ||
.option('-p, --http-port <n>', 'the http port to listen to', parseInt) | ||
.option('-a, --coap-port <n>', 'the coap port to listen to', parseInt) | ||
.option('--host <host>', 'the host to listen to') | ||
.option('--coap-host <host>', 'the host to listen to for coap requests') | ||
.option('--mqtt-host <host>', 'the host to listen to for mqtt requests') | ||
.option('--http-host <host>', 'the host to listen to for http requests') | ||
.option('-d, --db <path>', 'the path were to store the database') | ||
.option('-c, --config <c>', 'the config file to use (override every other option)') | ||
.option('-v, --verbose', 'set the bunyan log to INFO') | ||
.option('--very-verbose', 'set the bunyan log to DEBUG') | ||
|
||
program.parse(args) | ||
|
||
var opts = { | ||
logger: {}, | ||
http: {}, | ||
mqtt: {}, | ||
coap: {}, | ||
persistence: {} | ||
}; | ||
} | ||
|
||
if (program.verbose) { | ||
opts.logger.level = 30; | ||
opts.logger.level = 30 | ||
} else if (program.veryVerbose) { | ||
opts.logger.level = 20; | ||
opts.logger.level = 20 | ||
} | ||
|
||
if (program.httpPort) { | ||
opts.http.port = program.httpPort; | ||
opts.http.port = program.httpPort | ||
} | ||
|
||
if (program.mqttPort) { | ||
opts.mqtt.port = program.mqttPort; | ||
opts.mqtt.port = program.mqttPort | ||
} | ||
|
||
if (program.coapPort) { | ||
opts.coap.port = program.coapPort; | ||
opts.coap.port = program.coapPort | ||
} | ||
|
||
if (program.host) { | ||
opts.coap.host = program.host; | ||
opts.mqtt.host = program.host; | ||
opts.http.host = program.host; | ||
opts.coap.host = program.host | ||
opts.mqtt.host = program.host | ||
opts.http.host = program.host | ||
} | ||
|
||
if (program.coapHost) { | ||
opts.coap.host = program.coapHost; | ||
opts.coap.host = program.coapHost | ||
} | ||
|
||
if (program.mqttHost) { | ||
opts.mqtt.host = program.mqttHost; | ||
opts.mqtt.host = program.mqttHost | ||
} | ||
|
||
if (program.httpHost) { | ||
opts.http.host = program.httpHost; | ||
opts.http.host = program.httpHost | ||
} | ||
|
||
if (program.db) { | ||
opts.persistence.path = program.db; | ||
opts.persistence.type = "level"; | ||
opts.persistence.path = program.db | ||
opts.persistence.type = 'level' | ||
} | ||
|
||
if (program.config) { | ||
opts = require(path.resolve(program.config)); | ||
opts = require(path.resolve(program.config)) | ||
} | ||
|
||
return this(opts, done); | ||
}; | ||
return this(opts, done) | ||
} |
Oops, something went wrong.