probot/lib/context.js

25 lines
559 B
JavaScript

const Payload = require('./payload');
module.exports = class Context {
constructor(github, event) {
this.github = github;
this.event = event;
this.payload = new Payload(event.payload);
}
toRepo(object) {
const repo = this.payload.repository;
return Object.assign({
owner: repo.owner.login || repo.owner.name,
repo: repo.name
}, object);
}
toIssue(object) {
return Object.assign({
number: (this.payload.issue || this.payload.pull_request || this.payload).number
}, this.toRepo(), object);
}
};