mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-14 18:08:58 +08:00
Convert the rest of the files in `/src` and disable allowJs Move everything to named exports Update bin to use named exports Make all tests js and use named exports
36 lines
953 B
JavaScript
Executable File
36 lines
953 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
// Usage: bin/simulate issues path/to/payload app.js
|
|
|
|
require('dotenv').config({silent: true})
|
|
|
|
const path = require('path')
|
|
const program = require('commander')
|
|
const {findPrivateKey} = require('../lib/private-key')
|
|
|
|
program
|
|
.usage('[options] <event-name> <path/to/payload.json> [path/to/app.js...]')
|
|
.option('-a, --app <id>', 'ID of the GitHub App', process.env.APP_ID)
|
|
.option('-P, --private-key <file>', 'Path to certificate of the GitHub App', findPrivateKey)
|
|
.parse(process.argv)
|
|
|
|
const eventName = program.args[0]
|
|
const payloadPath = program.args[1]
|
|
|
|
if (!eventName || !payloadPath) {
|
|
program.help()
|
|
}
|
|
|
|
const payload = require(path.join(process.cwd(), payloadPath))
|
|
|
|
const {createProbot} = require('../')
|
|
|
|
const probot = createProbot({
|
|
id: program.app,
|
|
cert: findPrivateKey()
|
|
})
|
|
|
|
probot.setup(program.args.slice(2))
|
|
|
|
probot.logger.debug('Simulating event', eventName)
|
|
probot.receive({event: eventName, payload})
|