usmanyunusov / nano-staged

Tiny tool to run commands for modified, staged, and committed files in a GIT repository.
https://npm.im/nano-staged
MIT License
468 stars 14 forks source link

Prettify output log #13

Closed pustovalov closed 2 years ago

pustovalov commented 2 years ago

Hey, is it possible to improve the message nano-staged produces? When a user uses a git client that doesn't support colors, the message looks unreadable

Tower git client

lint-staged:

yarn run v1.22.17
$ /Users/pavel/t/main/node_modules/.bin/lint-staged
[STARTED] Preparing...
[SUCCESS] Preparing...
[STARTED] Running tasks...
[STARTED] Running tasks for *.{js,jsx,ts,tsx}
[STARTED] Running tasks for *.scss
[SKIPPED] No staged files match *.scss
[STARTED] eslint --fix
[FAILED] eslint --fix [FAILED]
[SUCCESS] Running tasks...
[STARTED] Applying modifications...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[SUCCESS] Reverting to original state because of errors...
[STARTED] Cleaning up...
[SUCCESS] Cleaning up...

✖ eslint --fix:

/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js
  442:12  error  Do not access a member directly from an await expression  unicorn/no-await-expression-member

✖ 1 problem (1 error, 0 warnings)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - pre-commit hook exited with code 1 (error)

nano-staged:

yarn run v1.22.17
$ /Users/pavel/t/main/node_modules/.bin/nano-staged
Nano Staged v0.4.1
- Preparing pipeliner...
  » Done backing up original repo state.
- Running tasks...
  *.scss            no staged files matching the pattern were found.
  *.{js,jsx,ts,tsx} eslint --fix
  *.{js,jsx,ts,tsx} stylelint --config '.stylelint_css_in_js.js' --syntax scss
- Restoring to its original state...
  » Done restoring up to its original state.
- Removing patch files...
  » Done removing up patch files.

eslint --fix:

/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js
  442:12  error  Do not access a member directly from an await expression  unicorn/no-await-expression-member

✖ 1 problem (1 error, 0 warnings)


Error
    at Object.runTasks (file:///Users/pavel/t/main/node_modules/nano-staged/lib/pipeliner.js:118:21)
    at async Object.backupUnstagedFiles (file:///Users/pavel/t/main/node_modules/nano-staged/lib/pipeliner.js:62:7)
    at async Object.run (file:///Users/pavel/t/main/node_modules/nano-staged/lib/pipeliner.js:42:7)
    at async run (file:///Users/pavel/t/main/node_modules/nano-staged/lib/run.js:58:5) {
  tasks: 'eslint --fix:\n' +
    '\x1B[0m\x1B[0m\n' +
    '\x1B[0m\x1B[4m/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js\x1B[24m\x1B[0m\n' +
    '\x1B[0m  \x1B[2m442:12\x1B[22m  \x1B[31merror\x1B[39m  Do not access a member directly from an await expression  \x1B[2municorn/no-await-expression-member\x1B[22m\x1B[0m\n' +
    '\x1B[0m\x1B[0m\n' +
    '\x1B[0m\x1B[31m\x1B[1m✖ 1 problem (1 error, 0 warnings)\x1B[22m\x1B[39m\x1B[0m\n' +
    '\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - pre-commit hook exited with code 1 (error)

Git console

lint-staged:

[~/t/main]$ git commit -m '.'                                                                                                                                                                                                 *[pp-js-deps][ruby-3.0.2@t]
yarn run v1.22.17
$ /Users/pavel/t/main/node_modules/.bin/lint-staged
✔ Preparing...
⚠ Running tasks...
  ❯ Running tasks for *.{js,jsx,ts,tsx}
    ✖ eslint --fix [FAILED]
    ◼ stylelint --config '.stylelint_css_in_js.js' --syntax scss
  ↓ No staged files match *.scss [SKIPPED]
↓ Skipped because of errors from tasks. [SKIPPED]
✔ Reverting to original state because of errors...
✔ Cleaning up...

✖ eslint --fix:

/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js
  442:12  error  Do not access a member directly from an await expression  unicorn/no-await-expression-member

✖ 1 problem (1 error, 0 warnings)

error Command failed with exit code 1.

nano-staged

[~/t/main]$ git commit -m '.'                                                                                                                                                                                                  [pp-js-deps][ruby-3.0.2@t]
yarn run v1.22.17
$ /Users/pavel/t/main/node_modules/.bin/nano-staged
Nano Staged v0.4.1
- Preparing pipeliner...
  » Done backing up original repo state.
- Running tasks...
  *.scss            no staged files matching the pattern were found.
  *.{js,jsx,ts,tsx} eslint --fix
  *.{js,jsx,ts,tsx} stylelint --config '.stylelint_css_in_js.js' --syntax scss
- Restoring to its original state...
  » Done restoring up to its original state.
- Removing patch files...
  » Done removing up patch files.

eslint --fix:

/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js
  442:12  error  Do not access a member directly from an await expression  unicorn/no-await-expression-member

✖ 1 problem (1 error, 0 warnings)

Error
    at Object.runTasks (file:///Users/pavel/t/main/node_modules/nano-staged/lib/pipeliner.js:118:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.backupUnstagedFiles (file:///Users/pavel/t/main/node_modules/nano-staged/lib/pipeliner.js:62:7)
    at async Object.run (file:///Users/pavel/t/main/node_modules/nano-staged/lib/pipeliner.js:42:7)
    at async run (file:///Users/pavel/t/main/node_modules/nano-staged/lib/run.js:58:5) {
  tasks: '\x1B[31meslint --fix:\n' +
    '\x1B[39m\x1B[0m\x1B[0m\n' +
    '\x1B[0m\x1B[4m/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js\x1B[24m\x1B[0m\n' +
    '\x1B[0m  \x1B[2m442:12\x1B[22m  \x1B[31merror\x1B[39m  Do not access a member directly from an await expression  \x1B[2municorn/no-await-expression-member\x1B[22m\x1B[0m\n' +
    '\x1B[0m\x1B[0m\n' +
    '\x1B[0m\x1B[31m\x1B[1m✖ 1 problem (1 error, 0 warnings)\x1B[22m\x1B[39m\x1B[0m\n' +
    '\x1B[0m\x1B[31m\x1B[1m\x1B[22m\x1B[39m\x1B[0m\n'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - pre-commit hook exited with code 1 (error)
usmanyunusov commented 2 years ago

@pustovalov

Fixed in release 0.4.5 Need to check

pustovalov commented 2 years ago

Thx, works good

yarn run v1.22.17
$ /Users/pavel/t/main/node_modules/.bin/nano-staged
Nano Staged v0.4.5
- Preparing pipeliner...
  » Done backing up original repo state.
- Running tasks...
  *.scss            | SKIPPED | no files matching the pattern were found.
  *.{js,jsx,ts,tsx} | FAILED  | eslint --fix
  *.{js,jsx,ts,tsx} | SKIPPED | stylelint --config '.stylelint_css_in_js.js' --syntax scss
- Restoring to its original state...
  » Done restoring up to its original state.
- Removing patch files...
  » Done removing up patch files.

eslint --fix:

/Users/pavel/t/main/app/javascript/__tests__/sites/reports/loyalty/loyalty_members_report/loyalty_member_details/loyalty_member_details_render.test.js
  442:12  error  Do not access a member directly from an await expression  unicorn/no-await-expression-member

✖ 1 problem (1 error, 0 warnings)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - pre-commit hook exited with code 1 (error)