From f39c2f6259bbd85b20c16815bc8560bc5fe38989 Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Sun, 19 Mar 2017 11:51:45 -0500 Subject: [PATCH] Look for private-key.pem --- bin/probot-run | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/bin/probot-run b/bin/probot-run index fb8f3017..f29996e6 100755 --- a/bin/probot-run +++ b/bin/probot-run @@ -9,14 +9,26 @@ program .option('-i, --integration ', 'ID of the GitHub Integration', process.env.INTEGRATION_ID) .option('-s, --secret ', 'Webhook secret of the GitHub Integration', process.env.WEBHOOK_SECRET || 'development') .option('-p, --port ', 'Port to start the server on', process.env.PORT || 3000) - .option('-c, --cert ', 'Path to certificate of the GitHub Integration', readCert, process.env.CERT || process.env.PRIVATE_KEY) + .option('-c, --cert ', 'Path to certificate of the GitHub Integration', path => { + try { + return require('fs').readFileSync(path); + } catch (err) { + console.warn(err.message); + process.exit(1); + } + }, process.env.CERT || process.env.PRIVATE_KEY) .parse(process.argv); -function readCert(path) { +if(!program.integration) { + console.warn("Missing GitHub Integration ID.\nUse --integration flag or set INTEGRATION_ID environment variable."); + program.help(); +} + +if(!program.cert) { try { - return require('fs').readFileSync(path); + program.cert = require('fs').readFileSync('private-key.pem'); } catch (err) { - console.warn(err.message); + console.warn("Missing GitHub Integration certificate.\nUse --cert flag or set CERT environment variable."); process.exit(1); } } @@ -25,16 +37,6 @@ const pkgConf = require('pkg-conf'); const resolve = require('resolve').sync; const createProbot = require('../'); -if(!program.integration) { - console.warn("Missing GitHub Integration ID.\nUse --integration flag or set INTEGRATION_ID environment variable."); - process.exit(1); -} - -if(!program.cert) { - console.warn("Missing GitHub Integration certificate.\nUse --cert flag or set CERT environment variable."); - process.exit(1); -} - const probot = createProbot({ id: program.integration, secret: program.secret,