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",
"strict": "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) {
// 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);

28
cli.js

@ -26,55 +26,43 @@ let cmdValue;
program
.version('0.2.1')
.arguments('<cmd>')
.action(function (cmd) {
cmdValue = cmd;
});
.action((cmd) => cmdValue = cmd);
program
.command('static <domain> [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 <domain> <inPort> [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 <domain> [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

Loading…
Cancel
Save