Skip to content

Commit

Permalink
Fixed code style
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Feb 4, 2017
1 parent 7a61d01 commit 485e5d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 15 additions & 9 deletions bin/micro
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ const args = parse(process.argv, {
p: 3000
}
})
let [,, file] = args._;

let [,, file] = args._

const help = () => {
console.log(`Usage: micro [opts] <file>
-H, --host Host to listen on [0.0.0.0]
-p, --port Port to listen on [3000]
-h, --help Show this help message`);
-h, --help Show this help message`)
}

if (args.h) {
help();
process.exit(0);
help()
process.exit(0)
}

if (!file) {
Expand All @@ -52,7 +53,7 @@ if (!file) {

if (!file) {
console.error('micro: Please supply a file.')
help();
help()
process.exit(1)
}

Expand All @@ -61,15 +62,18 @@ if ('/' !== file[0]) {
}

if (!isAsyncSupported()) {
require('async-to-gen/register')({ sourceMaps: DEV })
require('async-to-gen/register')({
sourceMaps: DEV
})
}

let mod

try {
mod = require(file);
mod = require(file)

if (mod && 'object' === typeof mod) {
mod = mod.default;
mod = mod.default
}
} catch (err) {
console.error(`micro: Error when importing ${file}: ${err.stack}`)
Expand All @@ -81,11 +85,13 @@ if ('function' !== typeof mod) {
process.exit(1)
}

const { port, host } = args
const {port, host} = args

serve(mod).listen(port, host, err => {
if (err) {
console.error('micro:', err.stack)
process.exit(1)
}

console.log(`> Ready! Listening on http://${host}:${port}`)
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"no-unused-labels": 0,
"no-unused-expressions": 0,
"yoda": 0,
"no-negated-condition": 0
"no-negated-condition": 0,
"import/no-dynamic-require": 0
}
},
"bin": {
Expand Down

0 comments on commit 485e5d2

Please sign in to comment.