forked from mirrors/probot
Support loading from script or module
This commit is contained in:
parent
dfba43664a
commit
e66acd40a4
14
bin/probot
14
bin/probot
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// TODO:
|
||||
// - exec specific script
|
||||
// - help
|
||||
|
||||
const path = require('path');
|
||||
const probot = require('../index.js');
|
||||
|
||||
const scripts = process.argv.slice(2);
|
||||
|
||||
scripts.forEach(script => {
|
||||
require(path.resolve(process.cwd(), script))(probot);
|
||||
});
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const resolve = require('resolve');
|
||||
const pkgConf = require('pkg-conf');
|
||||
const probot = require('../index.js');
|
||||
|
||||
function loadPlugins(plugins) {
|
||||
plugins.forEach(plugin => {
|
||||
resolve(plugin, {basedir: process.cwd()}, (err, path) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
} else {
|
||||
probot.log.trace('loading plugin %s', path);
|
||||
require(path)(probot);
|
||||
return path;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadPlugins(process.argv.slice(2));
|
||||
pkgConf('probot').then(pkg => loadPlugins(pkg.plugins || []));
|
|
@ -4,7 +4,7 @@
|
|||
"description": "a trainable robot that responds to activity on GitHub",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"probot": "./bin/probot"
|
||||
"probot": "./bin/probot.js"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
|
@ -16,7 +16,9 @@
|
|||
"bunyan": "^1.8.5",
|
||||
"dotenv-safe": "^4.0.3",
|
||||
"github-integration": "^1.0.0",
|
||||
"github-webhook-handler": "^0.6.0"
|
||||
"github-webhook-handler": "^0.6.0",
|
||||
"pkg-conf": "^2.0.0",
|
||||
"resolve": "^1.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expect": "^1.20.2",
|
||||
|
|
Loading…
Reference in New Issue