Browse Source

CRLF to LF

pull/10/head
Muthu Kumar 7 years ago
parent
commit
7864952e5f
  1. 3
      .eslintrc.json
  2. 7
      api.js
  3. 28
      cli.js

3
.eslintrc.json

@ -23,6 +23,7 @@
"no-var": "error", "no-var": "error",
"strict": "error", "strict": "error",
"eol-last": "error", "eol-last": "error",
"max-len": "error" "max-len": "error",
"no-unused-expressions": "error"
} }
} }

7
api.js

@ -18,7 +18,7 @@ const validate = require('./utils/validate');
function server (domain, outPort) { function server (domain, outPort) {
// If outport is not given, 80 is set as default. // If outport is not given, 80 is set as default.
// Later, change this default to reflect nginx's settings. // 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. // This is a string because regex needs to validate it.
if (!validate(domain, outPort)) return; if (!validate(domain, outPort)) return;
// Validates domain and outport, and if invalid, throws and returns. // Validates domain and outport, and if invalid, throws and returns.
@ -35,7 +35,8 @@ function server (domain, outPort) {
function proxy (domain, inPort, outPort) { function proxy (domain, inPort, outPort) {
// Inbound port is necessary, but outbound is set to 80 by default. // Inbound port is necessary, but outbound is set to 80 by default.
// Again, will change this to reflect nginx's settings. // 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. // This is a string because regex needs to validate it.
if (!validate(domain, inPort, outPort)) return; if (!validate(domain, inPort, outPort)) return;
createProxyServer(domain, inPort, outPort); createProxyServer(domain, inPort, outPort);
@ -52,7 +53,7 @@ function list () {
} }
function kill (domain, outPort) { function kill (domain, outPort) {
outPort = outPort || "80"; outPort = String(outPort) || "80";
// This is a string because regex needs to validate it. // This is a string because regex needs to validate it.
killServer(domain, outPort); killServer(domain, outPort);
console.log(EOL + "Done! Your server has been killed!"+ EOL); console.log(EOL + "Done! Your server has been killed!"+ EOL);

28
cli.js

@ -26,55 +26,43 @@ let cmdValue;
program program
.version('0.2.1') .version('0.2.1')
.arguments('<cmd>') .arguments('<cmd>')
.action(function (cmd) { .action((cmd) => cmdValue = cmd);
cmdValue = cmd;
});
program program
.command('static <domain> [outPort]') .command('static <domain> [outPort]')
.description('Create a static server at this folder.') .description('Create a static server at this folder.')
.action(function (domain, outPort) { .action((domain, outPort) => up.server(domain, outPort));
up.server(domain, outPort);
});
program program
.command('proxy <domain> <inPort> [outPort]') .command('proxy <domain> <inPort> [outPort]')
.description('Create a proxy server, listening at port number.') .description('Create a proxy server, listening at port number.')
.action(function (domain, inPort, outPort) { .action((domain, inPort, outPort) => up.proxy(domain, inPort, outPort));
up.proxy(domain, inPort, outPort);
});
program program
.command('list') .command('list')
.description('List all available servers.') .description('List all available servers.')
.action(function () { .action(() => up.list());
up.list();
});
program program
.command('kill <domain> [ourPort]') .command('kill <domain> [ourPort]')
.description('Kill a server.') .description('Kill a server.')
.action(function (domain, outPort) { .action((domain, outPort) => up.kill(domain, outPort));
up.kill(domain, outPort);
});
program program
.command('kill-all') .command('kill-all')
.description('Warning! Will completely kill all servers and reset nginx') .description('Warning! Will completely kill all servers and reset nginx')
.action(function() { .action(() => up.reset());
up.reset();
});
program program
.command('*') // This should pick invalid commands, but it doesn't, yet. .command('*') // This should pick invalid commands, but it doesn't, yet.
.action(function () { .action(() => {
console.log(EOL + "Invalid command. Type " + console.log(EOL + "Invalid command. Type " +
chalk.cyan('up --help') + " for help." + EOL); chalk.cyan('up --help') + " for help." + EOL);
}); });
// Adds custom help text to the automatically generated help. // Adds custom help text to the automatically generated help.
program.on('--help', function () { program.on('--help', () => {
console.log(EOL console.log(EOL
+ ' Usage:' + ' Usage:'
+ EOL + EOL

Loading…
Cancel
Save