-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·34 lines (29 loc) · 839 Bytes
/
index.js
File metadata and controls
executable file
·34 lines (29 loc) · 839 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
#!/usr/bin/env node
// In case picos was installed globally
const NP = process.env.NODE_PATH || ''
process.env.NODE_PATH = (NP ? NP + ':' : NP) + process.cwd() + '/node_modules'
require('module').Module._initPaths()
const book = require('./src/book')
const pipeline = require('./src/pipeline')
function run(opt, cb){
book.open(opt.service, async (err, service) => {
if (err) return cb(err)
cb(null, await pipeline.run(service, opt.mod, opt.ratelimit))
})
}
// Is run from cmd?
if (require.main === module) {
const args = require('pico-args')
const opt = args.parse({
service: ['service/index', 'path to service script'],
s: '@service',
mod: ['mod/', 'module path'],
m: '@service',
ratelimit: [64, 'ratelimit'],
r: '@ratelimit'
})
run(opt, err => {
if (err) return console.error(err)
})
}
module.exports = run