Skip to content

Commit

Permalink
Add warning if slack mention mapping file is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
tiloio committed Nov 19, 2020
1 parent 103bf17 commit d93ba39
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const core = require('@actions/core');
const https = require('https');
const fs = require('fs');
const path = require('path');

const inputSlackJson = core.getInput('slack_json');
const webHookUrl = core.getInput('slack_web_hook_url');
Expand All @@ -20,7 +21,12 @@ const slackMentionMapping = () => {
if (!slackMentionMappingFilePath) return null;

if (slackMentionMappingData == null) {
this.slackMentionMapping = JSON.parse(fs.readFileSync(slackMentionMappingFilePath, 'utf8'));
try {
this.slackMentionMapping = JSON.parse(fs.readFileSync(slackMentionMappingFilePath, 'utf8'));
} catch (error) {
core.warning('Could not get slack mention mapping! Looking for file at "' + path.resolve(slackMentionMappingFilePath) + '".\n' + error)
return null;
}
}

return this.slackMentionMapping;
Expand Down

0 comments on commit d93ba39

Please sign in to comment.