Skip to content

Commit

Permalink
merge configs when using extends
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix22 committed Jul 18, 2019
1 parent 21949c6 commit dc68d79
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@sentry/node": "^5.5.0",
"analytics-node": "^3.4.0-beta.1",
"bee-queue": "^1.2.2",
"lodash.merge": "^4.6.2",
"moment": "^2.24.0",
"ms": "^2.1.1",
"probot": "^9.2.19",
Expand Down
14 changes: 3 additions & 11 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const ms = require('ms')
const { Context } = require('probot')
const analytics = require('./analytics')
const merge = require('lodash.merge')

const { CLOSE, MERGE, LABEL } = require('./constants')

Expand Down Expand Up @@ -45,25 +45,17 @@ function createEvent(context, owner, repo) {
module.exports = async context => {
let config = await context.config(CONFIG_FILE, defaultConfig)

// TODO deprecated, remove
if (typeof config.uses === 'string' && config.uses.indexOf('/') > -1) {
const [owner, repo] = config.uses.split('/')
const globalContext = new Context(createEvent(context, owner, repo), context.github)
config = await globalContext.config(CONFIG_FILE, defaultConfig)
try {
analytics.track({
userId: context.payload.installation.id,
event: `Config using 'uses'`
})
} catch (e) {
// pass
}
}

if (typeof config.extends === 'string' && config.extends.indexOf('/') > -1) {
const [owner, repo] = config.extends.split('/')
const globalContext = new Context(createEvent(context, owner, repo), context.github)
config = await globalContext.config(CONFIG_FILE, defaultConfig)
const otherConfig = await globalContext.config(CONFIG_FILE, defaultConfig)
config = merge(otherConfig, config)
}

// merge defaults
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3955,6 +3955,11 @@ lodash.isstring@^4.0.1:
resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451"
integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=

lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==

lodash.omit@4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60"
Expand Down

0 comments on commit dc68d79

Please sign in to comment.