Skip to content

Commit

Permalink
feat: notify maintainers about configuration errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Jul 23, 2018
1 parent 65a019d commit 38614a9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"main": "src/index.js",
"scripts": {
"start": "probot run ./src/index.js",
"watch": "nodemon --exec 'npm start'",
"watch": "nodemon --exec 'yarn run start'",
"update": "ncu --upgrade --upgradeAll && yarn",
"push": "git push --follow-tags origin master",
"release": "standard-version && yarn run push"
Expand All @@ -25,6 +25,7 @@
"joi": "^13.3.0",
"probot": "^6.2.0",
"probot-config": "^0.1.0",
"probot-messages": "^0.1.0",
"probot-scheduler": "^1.1.0",
"uuid": "^3.2.1"
},
Expand Down
11 changes: 11 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const uuidV4 = require('uuid/v4');
const createScheduler = require('probot-scheduler');
const getMergedConfig = require('probot-config');
const sendMessage = require('probot-messages');

const App = require('./lock');
const schema = require('./schema');
Expand Down Expand Up @@ -40,6 +41,16 @@ module.exports = async robot => {
config = value;
} catch (err) {
log.warn({err: new Error(err), repo, file}, 'Invalid config');
if (['YAMLException', 'ValidationError'].includes(err.name)) {
await sendMessage(
robot,
context,
'[{appName}] Configuration error',
'[{appName}]({appUrl}) has encountered a configuration error in ' +
`\`${file}\`.\n\`\`\`\n${err.toString()}\n\`\`\``,
{update: 'The configuration error is still occurring.'}
);
}
}

return config;
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3074,6 +3074,10 @@ probot-config@^0.1.0:
dependencies:
js-yaml "^3.10.0"

probot-messages@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/probot-messages/-/probot-messages-0.1.0.tgz#0a6b279486b2bb40a25e37960f7341ac40e5b0c9"

probot-scheduler@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/probot-scheduler/-/probot-scheduler-1.1.0.tgz#eda193fd7faaf9a193a8b362903d78741dcda9b7"
Expand Down

0 comments on commit 38614a9

Please sign in to comment.