Skip to content

Commit

Permalink
ensure rootPath is always set when opts.useGitIgnore is true
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Oct 28, 2020
1 parent 33048ae commit 6abd959
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ Linter.prototype.parseOpts = function (opts) {
opts.eslintConfig.cwd = opts.cwd
opts.eslintConfig.fix = opts.fix

var packageOpts = opts.usePackageJson
? pkgConf.sync(self.cmd, { cwd: opts.cwd })
: {}
var packageOpts = {}
var rootPath = null

var rootPath = opts.usePackageJson
? path.dirname(pkgConf.filepath(packageOpts))
: null
if (opts.usePackageJson || opts.useGitIgnore) {
packageOpts = pkgConf.sync(self.cmd, { cwd: opts.cwd })
rootPath = path.dirname(pkgConf.filepath(packageOpts))
}

if (!opts.usePackageJson) packageOpts = {}

if (!packageOpts.noDefaultIgnore) {
addIgnore(DEFAULT_IGNORE)
Expand Down

0 comments on commit 6abd959

Please sign in to comment.