Skip to content

Commit 6abd959

Browse files
committedOct 28, 2020
ensure rootPath is always set when opts.useGitIgnore is true
1 parent 33048ae commit 6abd959

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

‎index.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,15 @@ Linter.prototype.parseOpts = function (opts) {
147147
opts.eslintConfig.cwd = opts.cwd
148148
opts.eslintConfig.fix = opts.fix
149149

150-
var packageOpts = opts.usePackageJson
151-
? pkgConf.sync(self.cmd, { cwd: opts.cwd })
152-
: {}
150+
var packageOpts = {}
151+
var rootPath = null
153152

154-
var rootPath = opts.usePackageJson
155-
? path.dirname(pkgConf.filepath(packageOpts))
156-
: null
153+
if (opts.usePackageJson || opts.useGitIgnore) {
154+
packageOpts = pkgConf.sync(self.cmd, { cwd: opts.cwd })
155+
rootPath = path.dirname(pkgConf.filepath(packageOpts))
156+
}
157+
158+
if (!opts.usePackageJson) packageOpts = {}
157159

158160
if (!packageOpts.noDefaultIgnore) {
159161
addIgnore(DEFAULT_IGNORE)

0 commit comments

Comments
 (0)
Please sign in to comment.