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

Better output on script error #14

Closed ai closed 2 years ago

ai commented 2 years ago

I have script to be sure that I changed versions everywhere. If I made a mistake, this script will exit with 1 code and prints:

Update pnpm version in .github/workflows/test.yml

I add this script to nano-staged and it works well. But nano-staged has unnecessary Error block at the end of output.

Current output:

Nano Staged v0.4.1
- Preparing pipeliner...
  » Done backing up original repo state.
- Running tasks...
  *.(js|ts)      no staged files matching the pattern were found.
  *.css          no staged files matching the pattern were found.
  *.svelte       no staged files matching the pattern were found.
  .tool-versions node ./scripts/check-versions.js
- Restoring to its original state...
  » Done restoring up to its original state.
- Removing patch files...
  » Done removing up patch files.

node ./scripts/check-versions.js:
Update pnpm version in .github/workflows/test.yml
Error
    at Object.runTasks (file:///home/ai/Dev/slowreader/node_modules/.pnpm/nano-staged@0.4.1/node_modules/nano-staged/lib/pipeliner.js:118:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.backupUnstagedFiles (file:///home/ai/Dev/slowreader/node_modules/.pnpm/nano-staged@0.4.1/node_modules/nano-staged/lib/pipeliner.js:62:7)
    at async Object.run (file:///home/ai/Dev/slowreader/node_modules/.pnpm/nano-staged@0.4.1/node_modules/nano-staged/lib/pipeliner.js:42:7)
    at async run (file:///home/ai/Dev/slowreader/node_modules/.pnpm/nano-staged@0.4.1/node_modules/nano-staged/lib/run.js:58:5) {
  tasks: '\x1B[31mnode ./scripts/check-versions.js:\n' +
    '\x1B[39mUpdate pnpm version in .github/workflows/test.yml'
}

Expected output:

Nano Staged v0.4.1
- Preparing pipeliner...
  » Done backing up original repo state.
- Running tasks...
  *.(js|ts)      no staged files matching the pattern were found.
  *.css          no staged files matching the pattern were found.
  *.svelte       no staged files matching the pattern were found.
  .tool-versions node ./scripts/check-versions.js
- Restoring to its original state...
  » Done restoring up to its original state.
- Removing patch files...
  » Done removing up patch files.

node ./scripts/check-versions.js:
Update pnpm version in .github/workflows/test.yml
usmanyunusov commented 2 years ago

Fixed in release 0.4.2

ai commented 2 years ago

Confirmed