|
1 | 1 | const ms = require('ms')
|
2 | 2 | const { Context } = require('probot')
|
3 | 3 | const merge = require('lodash.merge')
|
| 4 | +const Sentry = require('@sentry/node') |
4 | 5 |
|
5 | 6 | const { CLOSE, MERGE, LABEL } = require('./constants')
|
6 | 7 |
|
@@ -49,23 +50,32 @@ function createGlobalConfig(context, owner, repo) {
|
49 | 50 | }
|
50 | 51 |
|
51 | 52 | module.exports = async context => {
|
52 |
| - let config = await context.config(CONFIG_FILE, defaultConfig) |
| 53 | + try { |
| 54 | + let config = await context.config(CONFIG_FILE, defaultConfig) |
53 | 55 |
|
54 |
| - if (typeof config.uses === 'string' && config.uses.indexOf('/') > -1) { |
55 |
| - const [owner, repo] = config.uses.trim().split('/') |
56 |
| - config = await createGlobalConfig(context, owner, repo) |
57 |
| - } |
| 56 | + if (typeof config.uses === 'string' && config.uses.indexOf('/') > -1) { |
| 57 | + const [owner, repo] = config.uses.trim().split('/') |
| 58 | + config = await createGlobalConfig(context, owner, repo) |
| 59 | + } |
58 | 60 |
|
59 |
| - if (typeof config.extends === 'string' && config.extends.indexOf('/') > -1) { |
60 |
| - const [owner, repo] = config.extends.trim().split('/') |
61 |
| - const globalConfig = await createGlobalConfig(context, owner, repo) |
62 |
| - config = merge(globalConfig, config) |
63 |
| - } |
| 61 | + if (typeof config.extends === 'string' && config.extends.indexOf('/') > -1) { |
| 62 | + const [owner, repo] = config.extends.trim().split('/') |
| 63 | + const globalConfig = await createGlobalConfig(context, owner, repo) |
| 64 | + config = merge(globalConfig, config) |
| 65 | + } |
64 | 66 |
|
65 |
| - // merge defaults |
66 |
| - config.default = merge({}, defaultConfig.default, config.default) |
| 67 | + // merge defaults |
| 68 | + config.default = merge({}, defaultConfig.default, config.default) |
67 | 69 |
|
68 |
| - return config |
| 70 | + return config |
| 71 | + } catch (err) { |
| 72 | + Sentry.configureScope(scope => { |
| 73 | + const id = context.payload && context.payload.installation && context.payload.installation.id |
| 74 | + scope.setUser({ id }) |
| 75 | + Sentry.captureException(err) |
| 76 | + }) |
| 77 | + throw err |
| 78 | + } |
69 | 79 | }
|
70 | 80 |
|
71 | 81 | // console.log(require('js-yaml').safeDump(defaultConfig))
|
0 commit comments