Skip to content

Commit

Permalink
fix: also use .prettierignore from current working directory (prettie…
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Jan 15, 2019
1 parent 157d4b1 commit 3be3d08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -108,4 +108,4 @@ For example `pretty-quick --since HEAD` will format only staged files.

## Configuration and Ignore Files

`pretty-quick` will respect your [`.prettierrc`](https://prettier.io/docs/en/configuration), [`.prettierignore`](https://prettier.io/docs/en/ignore#ignoring-files), and [`.editorconfig`](http://editorconfig.org/) files, so there's no additional setup required. Configuration files will be found by searching up the file system. `.prettierignore` files are only found from the working directory that the command was executed from.
`pretty-quick` will respect your [`.prettierrc`](https://prettier.io/docs/en/configuration), [`.prettierignore`](https://prettier.io/docs/en/ignore#ignoring-files), and [`.editorconfig`](http://editorconfig.org/) files, so there's no additional setup required. Configuration files will be found by searching up the file system. `.prettierignore` files are only found from the repository root and the working directory that the command was executed from.
10 changes: 8 additions & 2 deletions src/index.js
Expand Up @@ -29,16 +29,22 @@ export default (

onFoundSinceRevision && onFoundSinceRevision(scm.name, revision);

const rootIgnorer = createIgnorer(directory);
const cwdIgnorer =
process.cwd() !== directory ? createIgnorer(process.cwd()) : () => true;

const changedFiles = scm
.getChangedFiles(directory, revision, staged)
.filter(isSupportedExtension)
.filter(createIgnorer(directory));
.filter(rootIgnorer)
.filter(cwdIgnorer);

const unstagedFiles = staged
? scm
.getUnstagedChangedFiles(directory, revision)
.filter(isSupportedExtension)
.filter(createIgnorer(directory))
.filter(rootIgnorer)
.filter(cwdIgnorer)
: [];

const wasFullyStaged = f => unstagedFiles.indexOf(f) < 0;
Expand Down

0 comments on commit 3be3d08

Please sign in to comment.