From 6ac666dfd89f4ea5ce4ef9004d1c2a2c85170f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20Ja=CC=88ppinen?= Date: Tue, 4 Jun 2019 15:00:37 +0300 Subject: [PATCH] feat: throw error in runAll if outside git directory --- README.md | 9 +++++---- src/runAll.js | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 946142a62..dec769dd9 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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": { @@ -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? diff --git a/src/runAll.js b/src/runAll.js index 94822427c..ddc6ea93d 100644 --- a/src/runAll.js +++ b/src/runAll.js @@ -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