Skip to content

Commit

Permalink
fix(gitDir): gitDir should only be applied when using git binary
Browse files Browse the repository at this point in the history
Inverses logic of checking for "not equal to `npm`", instead check
that binary to run is equal to `git` (and accounting for absolute
paths). This means that commands besides `npm` will also run in CWD
instead of `gitDir`.

Closes lint-staged#158
  • Loading branch information
Billy Vong committed May 16, 2017
1 parent 12e38f0 commit f0e082c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ module.exports = function runScript(commands, pathsToLint, packageJson, options)
task: () => {
try {
const res = findBin(linter, pathsToLint, packageJson, options)
// Only use gitDir as CWD if we are using the git binary
// e.g `npm` should run tasks in the actual CWD
const execaOptions =
res.bin !== 'npm' && options && options.gitDir ? { cwd: options.gitDir } : {}
res.bin.endsWith('git') && options && options.gitDir ? { cwd: options.gitDir } : {}
return new Promise((resolve, reject) => {
execa(res.bin, res.args, execaOptions)
.then(() => {
Expand All @@ -29,4 +31,3 @@ ${ err.stdout }`))
}
}))
}

0 comments on commit f0e082c

Please sign in to comment.