forked from mirrors/probot
Restore robot method and mark as deprecated
This commit is contained in:
parent
5bea838e33
commit
2ea6a5419b
8
index.js
8
index.js
|
@ -65,6 +65,14 @@ module.exports = (options = {}) => {
|
||||||
webhook,
|
webhook,
|
||||||
receive,
|
receive,
|
||||||
|
|
||||||
|
// Return the first robot
|
||||||
|
get robot() {
|
||||||
|
const caller = (new Error()).stack.split('\n')[2];
|
||||||
|
console.warn('DEPRECATED: the `robot` property is deprecated and will be removed in 0.10.0');
|
||||||
|
console.warn(caller);
|
||||||
|
return robots[0] || createRobot({app, cache, logger, catchErrors: true});
|
||||||
|
},
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
server.listen(options.port);
|
server.listen(options.port);
|
||||||
logger.trace('Listening on http://localhost:' + options.port);
|
logger.trace('Listening on http://localhost:' + options.port);
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = robot => {
|
||||||
|
console.log('laoded plugin');
|
||||||
|
}
|
|
@ -79,4 +79,21 @@ describe('Probot', () => {
|
||||||
expect(spy).toHaveBeenCalled();
|
expect(spy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('robot', () => {
|
||||||
|
it('will be removed in 0.10', () => {
|
||||||
|
const semver = require('semver');
|
||||||
|
const pkg = require('../package');
|
||||||
|
expect(semver.satisfies(pkg.version, '>=0.9')).toBe(false, 'remove in 0.10.0');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the first defined (for now)', () => {
|
||||||
|
const robot = probot.load(() => { });
|
||||||
|
expect(probot.robot).toBe(robot);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns a robot if no plugins are loaded', () => {
|
||||||
|
expect(probot.robot).toExist();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue