Restore robot method and mark as deprecated

This commit is contained in:
Brandon Keepers 2017-08-03 19:11:14 -05:00
parent 5bea838e33
commit 2ea6a5419b
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
3 changed files with 28 additions and 0 deletions

View File

@ -65,6 +65,14 @@ module.exports = (options = {}) => {
webhook,
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() {
server.listen(options.port);
logger.trace('Listening on http://localhost:' + options.port);

3
test/fixtures/example.js vendored Normal file
View File

@ -0,0 +1,3 @@
module.exports = robot => {
console.log('laoded plugin');
}

View File

@ -79,4 +79,21 @@ describe('Probot', () => {
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();
});
});
});