"Unable to get staged files" on Windows
See original GitHub issueA team member on Windows is having trouble using lint-staged set up on project
On our project we have both eslint and prettier using lint-staged with a husky precommit hook, here is the configuration in our package.json
:
"lint-staged": {
"**/*.{js,json}": [
"eslint --fix",
"prettier-eslint --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
We are using version 9.2.0
of lint-staged and 1.1.3
of husky.
Here are the outputs of multiple git commands for his project:
$ git status
On branch cleaner_test_fixes
Your branch is up to date with 'origin/cleaner_test_fixes'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: readme.md
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: package.json
$ git diff --staged
diff --git a/readme.md b/readme.md
index 3443791..fd686f3 100755
--- a/readme.md
+++ b/readme.md
@@ -1,4 +1,4 @@
-# Spec Service
+# Spec Service blah
## Introduction
@@ -50,4 +50,4 @@ need bearer token
* http://<url-removed>/repos/specservice/browse
## CI
-* http://<url-removed>/browse/CDKEX-SPEC
\ No newline at end of file
+* http://<url-removed>/browse/CDKEX-SPEC
$ git diff --staged --diff-filter=ACM --name-only
readme.md
The configuration works for the team members using MacOS as expected
Debug Logs
expand to view
$ git commit
husky > pre-commit (node v8.12.0)
2019-07-26T13:50:31.861Z lint-staged:bin Running `lint-staged@9.2.1`
2019-07-26T13:50:31.862Z lint-staged Loading config using `cosmiconfig`
2019-07-26T13:50:31.872Z lint-staged Successfully loaded config from `C:\src\fortellis\clean2\specservice\package.json`:
{ '**/*.{js,json}': [ 'eslint --fix', 'prettier-eslint --write', 'git add' ] }
2019-07-26T13:50:31.872Z lint-staged:cfg Validating config
Running lint-staged with the following config:
{
'**/*.{js,json}': [
'eslint --fix',
'prettier-eslint --write',
'git add'
]
}
2019-07-26T13:50:31.873Z lint-staged:run Running all linter scripts
2019-07-26T13:50:31.873Z lint-staged:git Running git command [ 'rev-parse', '--show-toplevel' ]
2019-07-26T13:50:31.973Z lint-staged:run Resolved git directory to be `\cygdrive\c\src\fortellis\clean2\specservice`
2019-07-26T13:50:31.973Z lint-staged:git Running git command [ 'diff', '--staged', '--diff-filter=ACM', '--name-only' ]
Unable to get staged files!
husky > pre-commit hook failed (add --no-verify to bypass)
Environment
- OS: Windows 10 Enterprise w/ Cygwin
- Node.js: 8.12.0
lint-staged
: 9.2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
'lint-staged' is not recognized as an internal or external ...
When using cmd.exe or Visual Studio Code in Windows I get the error "'lint-staged' is not recognized as an internal or external command, ......
Read more >Git Changes - unable stage additional files
When staging files for commit via the new Git Changes experience, I am unable to stage additional files after the first set. For...
Read more >Adding file to git's stage does nothing and cannot be committed
I have run into this same situation where I add or modify few files and they start showing as both staged and unstaged....
Read more >Unable to deselect files | Sourcetree for Windows
In the "Staged files" and "Unstaged files" lists you cannot deselect a file without selecting a different file. So if you have all...
Read more >pre-commit
Before you can run hooks, you need to have the pre-commit package manager ... pre-commit run flake8 : run the flake8 hook against...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s a new PR https://github.com/okonet/lint-staged/pull/678 that always converts paths to forward-slashes. Maybe it helps here.
Having a similar issue. Debug output:
I’m in a msys2 environment, similar to cygwin (which @Jaredk3nt ) is using. It’s not the diff that’s failing really, it’s what
resolveGitDir
is returning as the git directory, which has incorrect path separators (they should be unix-style), which I’m guessing is caused bypath.normalize
. I see that it was included to fix tests here, but is it really necessary? Windows can handle using forward slashes as a path separator.