Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose output on windows #1277

Closed
sebastianbuechler opened this issue Mar 17, 2023 · 8 comments · Fixed by #1370
Closed

Verbose output on windows #1277

sebastianbuechler opened this issue Mar 17, 2023 · 8 comments · Fixed by #1370

Comments

@sebastianbuechler
Copy link

Description

I just added lint-staged to my project and it works fine. However, the output seems to be quite verbose and not nicely formatted as I saw it in examples.

Steps to reproduce

Configure minimal example and make a commit to trigger the hook.

Output:

$ git commit -m "fix misconfiguration"
yarn run v1.22.19
$ C:\Users\myuser\Dev\TypeScript\Project\node_modules\.bin\lint-staged
[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...
[STARTED] package.json — 1 file
[STARTED] *.{js,jsx,ts,tsx} — 0 files
[STARTED] *.{scss,css,json} — 1 file
[SKIPPED] *.{js,jsx,ts,tsx} — no files
[STARTED] prettier --write
[SUCCESS] prettier --write
[SUCCESS] *.{scss,css,json} — 1 file
[SUCCESS] package.json — 1 file
[SUCCESS] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SUCCESS] Applying modifications from tasks...
[STARTED] Cleaning up temporary files...
[SUCCESS] Cleaning up temporary files...
Done in 0.82s.
[feature/add-pre-commit-hooks f0455cd] fix misconfiguration
 1 file changed, 2 insertions(+), 2 deletions(-)

Wanted:
Something in the style of this:
image

Environment

  • OS: Windows 11
  • lint-staged: 13.2.0
  • Terminal: git bash
@jerkovicl
Copy link

yeah same for me, it was prettier in previous versions

@greenhat616
Copy link

same issues

@iiroj
Copy link
Member

iiroj commented Nov 22, 2023

Lint-staged relies on Listr2 to determine how the log should look like. You can play around with this file to see if you manage to make it look nicer, unfortunately I don't have a Windows machine myself to debug: https://github.com/lint-staged/lint-staged/blob/master/lib/getRenderer.js

EDIT: For example, forcing renderer: 'update' might work; if that's the case there's probably something wrong with the automatic detection.

@greenhat616
Copy link

greenhat616 commented Nov 22, 2023

Lint-staged relies on Listr2 to determine how the log should look like. You can play around with this file to see if you manage to make it look nicer, unfortunately I don't have a Windows machine myself to debug: https://github.com/lint-staged/lint-staged/blob/master/lib/getRenderer.js

EDIT: For example, forcing renderer: 'update' might work; if that's the case there's probably something wrong with the automatic detection.

@iiroj Thank you. I will have a try later.

what i want to attach, is that:

  1. run lint-staged directly, it was normal:
    image

  2. run lint-staged in Git Hooks, it was in verbose mode.
    image

@iiroj
Copy link
Member

iiroj commented Nov 30, 2023

@iiroj iiroj closed this as completed Nov 30, 2023
@greenhat616
Copy link

This is probably related to the issue described in our FAQ: https://github.com/lint-staged/lint-staged?tab=readme-ov-file#the-output-of-commit-hook-looks-weird-no-colors-duplicate-lines-

No, git version is 2.43.

git -v                                                                                               16:52:13  
git version 2.43.0.windows.1

So it should report to git team?

@iiroj
Copy link
Member

iiroj commented Dec 1, 2023

Does this help? If so, I can add it directly to the README: typicode/husky#968 (comment)

EDIT: That is, adding this to your husky script before npx lint-staged

# If tty is available, apply fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec >/dev/tty 2>&1; fi

@greenhat616
Copy link

Does this help? If so, I can add it directly to the README: typicode/husky#968 (comment)

EDIT: That is, adding this to your husky script before npx lint-staged

# If tty is available, apply fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then exec >/dev/tty 2>&1; fi

image

Yes, after add this line to huksy, it work as expect. Thanks you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants