-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.js
More file actions
executable file
·36 lines (34 loc) · 825 Bytes
/
bin.js
File metadata and controls
executable file
·36 lines (34 loc) · 825 Bytes
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
#!/usr/bin/env node
/**
* @file bin
* @author imcuttle <[email protected]>
* @date 2019/8/15
*
*/
var express = require('express')
var opts = require('optimist')
.usage('Usage: $0 [options]')
.string(['config-file'])
.describe({
'config-file':
'Assign configuration file, It will find up the closest file named `hotproxy.config.js` when not setting.'
})
.default({
'config-file': null,
port: 8080,
host: null
})
var argv = opts.argv
if (argv.help) {
opts.showHelp()
} else {
var app = express()
app.use(require('.').hotProxy(argv['config-file'])).listen(argv.port, argv.host, function(err) {
if (err) {
console.error(err)
process.exit(1)
return
}
console.log('Hot Proxy Server running on http://%s:%s', argv.host || 'localhost', argv.port)
})
}