Skip to content

Commit

Permalink
fix: do not add dependabot files when config is falsy
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Jul 7, 2023
1 parent 4624d9c commit 710c25e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const sharedRootAdd = (name) => ({
// dependabot
'.github/dependabot.yml': {
file: 'dependabot.yml',
filter: (p) => p.config.dependabot,
clean: (p) => p.config.isRoot,
// dependabot takes a single top level config file. this parser
// will run for all configured packages and each one will have
Expand All @@ -48,6 +49,7 @@ const sharedRootAdd = (name) => ({
},
'.github/workflows/post-dependabot.yml': {
file: 'post-dependabot.yml',
filter: (p) => p.config.dependabot,
},
'.github/settings.yml': {
file: 'settings.yml',
Expand Down
30 changes: 30 additions & 0 deletions test/apply/dependabot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const t = require('tap')
const setup = require('../setup.js')

t.test('default dependabot', async (t) => {
const s = await setup(t)
await s.apply()

const dependabot = await s.readFile('.github/dependabot.yml')
const postDependabot = await s.stat('.github/workflows/post-dependabot.yml')

t.match(dependabot, 'increase-if-necessary')
t.ok(postDependabot)
})

t.test('no dependabot', async (t) => {
const s = await setup(t, {
package: {
templateOSS: {
dependabot: false,
},
},
})
await s.apply()

const dependabot = await s.stat('.github/dependabot.yml').catch(() => false)
const postDependabot = await s.stat('.github/workflows/post-dependabot.yml').catch(() => false)

t.equal(dependabot, false)
t.equal(postDependabot, false)
})

0 comments on commit 710c25e

Please sign in to comment.