Skip to content

Commit

Permalink
feat: throw error in runAll if outside git directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Iiro Jäppinen authored and okonet committed Jun 6, 2019
1 parent defcdfc commit 6ac666d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -25,7 +25,7 @@ The fastest way to start using lint-staged is to run following command in your t

```bash
npx mrm lint-staged
```
```

It will install and configure [husky](https://github.com/typicode/husky) and lint-staged depending on code quality tools from `package.json` dependencies so please make sure you install (`npm install --save-dev`) and configure all code quality tools like [Prettier](https://prettier.io), [ESlint](https://eslint.org) prior that.

Expand Down Expand Up @@ -346,6 +346,7 @@ When using the IDE's GUI to commit changes with the `precommit` hook, you might
Until the issue is resolved in the IDE, you can use the following config to work around it:

husky v1.x

```json
{
"husky": {
Expand All @@ -358,16 +359,16 @@ husky v1.x
```

husky v0.x

```json
{
"scripts": {
"precommit": "lint-staged",
"postcommit": "git update-index --again"
"precommit": "lint-staged",
"postcommit": "git update-index --again"
}
}
```


_Thanks to [this comment](https://youtrack.jetbrains.com/issue/IDEA-135454#comment=27-2710654) for the fix!_

### How to use `lint-staged` in a multi package monorepo?
Expand Down
7 changes: 6 additions & 1 deletion src/runAll.js
Expand Up @@ -24,7 +24,12 @@ module.exports = async function runAll(config) {
}

const { concurrent, renderer, chunkSize, subTaskConcurrency } = config
const gitDir = await resolveGitDir()
const gitDir = await resolveGitDir(config)

if (!gitDir) {
throw new Error('Current directory is not a git directory!')
}

debug('Resolved git directory to be `%s`', gitDir)

sgf.cwd = gitDir
Expand Down

0 comments on commit 6ac666d

Please sign in to comment.