From c53edd6502e24d557faae92287bb0b993da783bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julia=20Kr=C3=BCger?= Date: Thu, 22 Feb 2018 16:53:23 +0100 Subject: [PATCH] feat(get-config): get config from greenkeeper config file if present rather then from root package.json --- lib/get-config.js | 4 +++- test/lib/get-config.js | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/get-config.js b/lib/get-config.js index 7ef86a9f..64b916ed 100644 --- a/lib/get-config.js +++ b/lib/get-config.js @@ -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'], {} diff --git a/test/lib/get-config.js b/test/lib/get-config.js index 11afe015..8744a097 100644 --- a/test/lib/get-config.js +++ b/test/lib/get-config.js @@ -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)