Skip to content

Commit

Permalink
fix(get-config): don‘t mutate original config in repo doc
Browse files Browse the repository at this point in the history
  • Loading branch information
espy authored and janl committed Apr 6, 2018
1 parent e597e6b commit 98144d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = repository => {
{}
)

return _.defaultsDeep(config, {
// Make a copy instead of mutating the original repoDoc config!
return _.defaultsDeep(JSON.parse(JSON.stringify(config)), {
label: 'greenkeeper',
branchPrefix: 'greenkeeper/',
ignore: [],
Expand Down
4 changes: 3 additions & 1 deletion test/jobs/create-initial-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ describe('create initial branch', () => {
'@finnpauls/dep2': '1.0.0'
}

expect.assertions(19)
expect.assertions(20)

nock('https://api.github.com')
.post('/installations/137/access_tokens')
Expand Down Expand Up @@ -738,6 +738,8 @@ describe('create initial branch', () => {
// is no longer in the repo
const transformedConfigFile = transforms[0].transform()
const parsedConfigFile = JSON.parse(transformedConfigFile)
// Check that we don’t add Greenkeeper system defaults to the actual greenkeeper.json file
expect(parsedConfigFile.commitMessages).toBeFalsy()
expect(parsedConfigFile.groups).toMatchObject({
build: {
packages: [
Expand Down

0 comments on commit 98144d1

Please sign in to comment.