Skip to content

Commit

Permalink
feat: ignore node_modules when finding package.jsons
Browse files Browse the repository at this point in the history
  • Loading branch information
janl committed Apr 16, 2018
1 parent b44cd1a commit d2dbf50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/ignores.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs')
module.exports = function ignores () {
const ignoreFile = '.gitignore'
if (!fs.fileExistsSync(ignoreFile)) {
return []
}

const ignoreContents = fs.readFileSync(ignoreFile)
return ignoreFile.split('\n') || []
}
4 changes: 3 additions & 1 deletion update.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const relative = require('require-relative')
const fg = require('fast-glob')

const config = require('./lib/config')
const ignores = require('./lib/ignores')
const extractDependency = require('./lib/extract-dependency')
const hasLockfileCommit = require('./lib/git-helpers').hasLockfileCommit

Expand Down Expand Up @@ -43,7 +44,8 @@ module.exports = function update () {
return console.error('greenkeeper-lockfile already has a commit on this branch')
}

const allPackageFiles = fg.sync('./**/package.json')
const ignores = getIgnores()
const allPackageFiles = fg.sync('./**/package.json', {ignore: ignores})
const doCommit = allPackageFiles.reduce((didChange, pkgJson) => {
const lockfilePath = path.dirname(pkgJson)
const previousDir = process.cwd()
Expand Down

0 comments on commit d2dbf50

Please sign in to comment.