mirror of
https://github.com/danbulant/koa-plugins
synced 2026-05-19 04:08:43 +00:00
39 lines
No EOL
1 KiB
JavaScript
39 lines
No EOL
1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
global.argv = require('yargs')
|
|
|
|
const chalk = require("chalk");
|
|
console = (function(oldCons){
|
|
return {
|
|
log: function(...text){
|
|
oldCons.log(...text);
|
|
},
|
|
info: function(...text){
|
|
oldCons.info("[INFO]", ...text);
|
|
},
|
|
warn: function (...text) {
|
|
oldCons.warn(chalk.yellow("[WARN]", ...text));
|
|
},
|
|
error: function (...text) {
|
|
oldCons.error(chalk.red("[ERROR]", ...text));
|
|
}
|
|
};
|
|
}(console));
|
|
|
|
var argv = global.argv
|
|
.command('start [port]', 'Starts the server', (yargs) => {
|
|
yargs
|
|
.positional('port', {
|
|
describe: 'Port to bind on. Requires sudo on <1024',
|
|
default: 80
|
|
})
|
|
}, (argv) => {
|
|
console.info(`starting server on :${argv.port}`)
|
|
require("../index.js")(argv.port);
|
|
})
|
|
.option('verbose', {
|
|
alias: 'v',
|
|
type: 'boolean',
|
|
description: 'Run with verbose logging'
|
|
})
|
|
.argv |