Skip to content

Commit

Permalink
feat(get-config): get config from greenkeeper config file if present
Browse files Browse the repository at this point in the history
rather then from root package.json
  • Loading branch information
Realtin authored and hulkoba committed Mar 26, 2018
1 parent 9eb2b5f commit c53edd6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const _ = require('lodash')
const { defaultCommitMessages } = require('./default-commit-messages')

module.exports = repository => {
const config = _.get(
const config = _.has(repository, 'greenkeeper')
? _.get(repository, 'greenkeeper')
: _.get(
repository,
['packages', 'package.json', 'greenkeeper'],
{}
Expand Down
46 changes: 46 additions & 0 deletions test/lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,52 @@ test('get default config', () => {
expect(getConfig(repository)).toEqual(expected)
})

test('get config from root greenkeeper section', () => {
expect.assertions(1)

const repository = {
packages: {
'package.json': {}
},
greenkeeper: {
groups: {
backend: {
ignore: [
'lodash'
],
packages: [
'apps/backend/hapiserver/package.json'
]
}
}
}
}

const expected = {
label: 'greenkeeper',
branchPrefix: 'greenkeeper/',
ignore: [],
commitMessages: {
initialBadge: 'docs(readme): add Greenkeeper badge',
initialDependencies: 'chore(package): update dependencies',
initialBranches: 'chore(travis): whitelist greenkeeper branches',
dependencyUpdate: 'fix(package): update ${dependency} to version ${version}',
devDependencyUpdate: 'chore(package): update ${dependency} to version ${version}',
dependencyPin: 'fix: pin ${dependency} to ${oldVersion}',
devDependencyPin: 'chore: pin ${dependency} to ${oldVersion}',
closes: '\n\nCloses #${number}'
},
groups: {
backend: {
ignore: ['lodash'],
packages: ['apps/backend/hapiserver/package.json']
}
}
}

expect(getConfig(repository)).toMatchObject(expected)
})

test('get custom commit message', () => {
expect.assertions(1)

Expand Down

0 comments on commit c53edd6

Please sign in to comment.