diff --git a/.eslintrc.js b/.eslintrc.js index 095799d..c939a3b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,7 +15,6 @@ module.exports = { "prefer-const": 1, // 4 errors "no-unused-vars": 1, // 3 errors "no-use-before-define": 1, // 7 errors - "one-var": 1, // 8 errors "consistent-return": 1, // 8 errors "no-param-reassign": 1, // 2 errors "global-require": 1, // 2 errors diff --git a/lib/cli/keygen.js b/lib/cli/keygen.js index f7f39e9..358bced 100644 --- a/lib/cli/keygen.js +++ b/lib/cli/keygen.js @@ -4,8 +4,8 @@ * Generate a key */ const keygen = function () { - const Keys = require('../keys'), - keys = new Keys(); + const Keys = require('../keys'); + const keys = new Keys(); keys.create((err, key) => { if (err) return console.error(err); diff --git a/lib/cli/showkey.js b/lib/cli/showkey.js index aaf262a..629925d 100644 --- a/lib/cli/showkey.js +++ b/lib/cli/showkey.js @@ -4,8 +4,8 @@ * Show current key */ const showkey = function () { - const Keys = require('../keys'), - keys = new Keys(); + const Keys = require('../keys'); + const keys = new Keys(); keys.getLocal((err, key) => { if (err) return console.error(err); diff --git a/lib/cli/start.js b/lib/cli/start.js index 98a4369..61c33c6 100644 --- a/lib/cli/start.js +++ b/lib/cli/start.js @@ -28,13 +28,13 @@ const createServer = require('./createserver'); * Start the server */ const start = function (file) { - let port = program.port, - host = program.host || '127.0.0.1', - dbname = program.dbname || '-deployd', - mongoPort = generatePort(), - env = program.environment || process.env.DPD_ENV || 'development', - retries = 0, - credentials = {}; + let port = program.port; + const host = program.host || '127.0.0.1'; + const dbname = program.dbname || '-deployd'; + const mongoPort = program.mongoPort ? Number(program.mongoPort) : '27017'; + const env = program.environment || process.env.DPD_ENV || 'development'; + let retries = 0; + const credentials = {}; if (!port) { @@ -42,10 +42,6 @@ const start = function (file) { retries = env === 'development' && 5; } - if (program.mongoPort) { - mongoPort = Number(program.mongoPort); - } - if (file) { process.chdir(path.dirname(file)); } @@ -98,9 +94,9 @@ const start = function (file) { if (program.host) { if (program.auth) { - const auth = program.auth.split(':'), - username = auth[0], - password = auth[1]; + const auth = program.auth.split(':'); + const username = auth[0]; + const password = auth[1]; setCredentials(username, password); } else if (program.username || program.password) { setCredentials(program.username, program.password); @@ -170,14 +166,6 @@ const start = function (file) { } }; -/** - * Port generation - */ -function generatePort() { - const portRange = [3000, 9000]; - return Math.floor(Math.random() * (portRange[1] - portRange[0])) + portRange[0]; -} - function checkForUpdates() { http.get('http://registry.npmjs.org/deployd-cli', (err, res, body) => { if (!err) { diff --git a/lib/keys.js b/lib/keys.js index 49c2425..c8ee9ba 100644 --- a/lib/keys.js +++ b/lib/keys.js @@ -35,8 +35,8 @@ Keys.prototype.generate = function () { */ Keys.prototype.create = function (fn) { - const key = this.generate(), - keys = this; + const key = this.generate(); + const keys = this; this.readFile((err, data) => { if (err) return fn(err); @@ -54,8 +54,8 @@ Keys.prototype.create = function (fn) { Keys.prototype.readFile = function (fn) { fs.readFile(this.path, 'utf-8', (err, data) => { - let jsonData, - error; + let jsonData; + let error; try { jsonData = (data && JSON.parse(data)) || {};