forked from mirrors/probot
Get simulate working again
This commit is contained in:
parent
f8890cbb41
commit
0bbd9d182c
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env node
|
||||
// Usage: bin/simulate issues path/to/payload plugin.js
|
||||
|
||||
require('dotenv').config({silent: true});
|
||||
|
||||
const process = require('process');
|
||||
const path = require('path')
|
||||
|
||||
const eventName = process.argv[2];
|
||||
const payloadPath = process.argv[3];
|
||||
const pluginPath = process.argv[4];
|
||||
|
||||
if(!eventName || !payloadPath) {
|
||||
console.log("Usage: script/simulate event-name path/to/payload.json");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const payload = require(path.join(process.cwd(), payloadPath));
|
||||
|
||||
const createProbot = require('../');
|
||||
const {findPrivateKey} = require('../lib/private-key');
|
||||
|
||||
const probot = createProbot({
|
||||
id: process.env.INTEGRATION_ID,
|
||||
secret: process.env.WEBHOOK_SECRET,
|
||||
cert: findPrivateKey(),
|
||||
port: process.env.PORT
|
||||
});
|
||||
|
||||
const plugins = require('../lib/plugin')(probot);
|
||||
plugins.load([pluginPath]);
|
||||
|
||||
console.log("Simulating event", eventName);
|
||||
probot.robot.webhook.emit(eventName, {event: eventName, payload});
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
// Usage: script/simulate issues path/to/payload
|
||||
|
||||
require('dotenv').config({silent: true});
|
||||
|
||||
const process = require('process');
|
||||
const path = require('path')
|
||||
|
||||
const eventName = process.argv[2];
|
||||
const payloadPath = process.argv[3];
|
||||
|
||||
if(!eventName || !payloadPath) {
|
||||
console.log("Usage: script/simulate event-name path/to/payload.json");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Show trace for any unhandled rejections
|
||||
process.on('unhandledRejection', reason => console.error(reason));
|
||||
|
||||
const robot = require('../lib/robot');
|
||||
const payload = require(path.join(process.cwd(), payloadPath));
|
||||
|
||||
console.log("Simulating event", eventName);
|
||||
|
||||
robot.receive({event: eventName, payload});
|
Loading…
Reference in New Issue