Get simulate working again

This commit is contained in:
Brandon Keepers 2017-05-03 11:54:28 -05:00
parent f8890cbb41
commit 0bbd9d182c
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
2 changed files with 34 additions and 25 deletions

34
bin/probot-simulate Executable file
View File

@ -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});

View File

@ -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});