From 7864952e5fcfc52b80c6df4c97824a83f5ab603b Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Thu, 30 Nov 2017 02:05:28 +0530 Subject: [PATCH] CRLF to LF --- .eslintrc.json | 3 ++- api.js | 7 ++++--- cli.js | 28 ++++++++-------------------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index d9aca22..0af9758 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,6 +23,7 @@ "no-var": "error", "strict": "error", "eol-last": "error", - "max-len": "error" + "max-len": "error", + "no-unused-expressions": "error" } } \ No newline at end of file diff --git a/api.js b/api.js index 3aa88e5..b80cb68 100644 --- a/api.js +++ b/api.js @@ -18,7 +18,7 @@ const validate = require('./utils/validate'); function server (domain, outPort) { // If outport is not given, 80 is set as default. // Later, change this default to reflect nginx's settings. - outPort = outPort || "80"; + outPort = String(outPort) || "80"; // This is a string because regex needs to validate it. if (!validate(domain, outPort)) return; // Validates domain and outport, and if invalid, throws and returns. @@ -35,7 +35,8 @@ function server (domain, outPort) { function proxy (domain, inPort, outPort) { // Inbound port is necessary, but outbound is set to 80 by default. // Again, will change this to reflect nginx's settings. - outPort = outPort || "80"; + outPort = String(outPort) || "80"; + inPort = String(inPort); // This is a string because regex needs to validate it. if (!validate(domain, inPort, outPort)) return; createProxyServer(domain, inPort, outPort); @@ -52,7 +53,7 @@ function list () { } function kill (domain, outPort) { - outPort = outPort || "80"; + outPort = String(outPort) || "80"; // This is a string because regex needs to validate it. killServer(domain, outPort); console.log(EOL + "Done! Your server has been killed!"+ EOL); diff --git a/cli.js b/cli.js index 546b0ea..74ecbef 100644 --- a/cli.js +++ b/cli.js @@ -26,55 +26,43 @@ let cmdValue; program .version('0.2.1') .arguments('') - .action(function (cmd) { - cmdValue = cmd; - }); + .action((cmd) => cmdValue = cmd); program .command('static [outPort]') .description('Create a static server at this folder.') - .action(function (domain, outPort) { - up.server(domain, outPort); - }); + .action((domain, outPort) => up.server(domain, outPort)); program .command('proxy [outPort]') .description('Create a proxy server, listening at port number.') - .action(function (domain, inPort, outPort) { - up.proxy(domain, inPort, outPort); - }); + .action((domain, inPort, outPort) => up.proxy(domain, inPort, outPort)); program .command('list') .description('List all available servers.') - .action(function () { - up.list(); - }); + .action(() => up.list()); program .command('kill [ourPort]') .description('Kill a server.') - .action(function (domain, outPort) { - up.kill(domain, outPort); - }); + .action((domain, outPort) => up.kill(domain, outPort)); program .command('kill-all') .description('Warning! Will completely kill all servers and reset nginx') - .action(function() { - up.reset(); - }); + .action(() => up.reset()); program .command('*') // This should pick invalid commands, but it doesn't, yet. - .action(function () { + .action(() => { console.log(EOL + "Invalid command. Type " + chalk.cyan('up --help') + " for help." + EOL); }); // Adds custom help text to the automatically generated help. -program.on('--help', function () { +program.on('--help', () => { console.log(EOL + ' Usage:' + EOL