-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbin.js
More file actions
executable file
·55 lines (50 loc) · 1.58 KB
/
bin.js
File metadata and controls
executable file
·55 lines (50 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env node
const debug = require('debug')('github-similar-server:cli')
const argv = require('minimist')(process.argv.slice(2))
const server = require('./')
const opt = {
help: argv.h || argv.help,
port: argv.p || argv.port || 8080,
version: argv.v || argv.version,
disableMarkdown: !!argv['disable-markdown'],
disableStatic: !!argv['disable-static'],
markdownTemplate: argv['markdown-template'],
markdownTemplateString: argv['markdown-template-string'],
silent: !!argv['silent'],
root: (argv._ && argv._[0]) || process.cwd()
}
debug('argv', argv)
debug('opt', opt)
;(function() {
if (opt.version) {
console.log(require('./package').version)
return
}
if (opt.help) {
console.log(`
Usage
$ github-similar-server [path] <options>
Options
-h, --help Show help
-v, --version Show version
-p, --port Set server's port [default 8080]
--silent Do not log anything [default false]
--disable-markdown Disable markdown render
--disable-static Disable static file service
--markdown-template The template of markdown's template
--markdown-template-string The template string source of markdown's template
`)
return
}
server({
port: opt.port,
enableMarkdown: !opt.disableMarkdown,
enableStatic: !opt.disableStatic,
root: opt.root,
silent: opt.silent,
markdownTemplate: opt.markdownTemplate
}).catch(e => {
console.error(e)
process.exit(1)
})
})()