Skip to content

vp fmt errors when all input files are excluded by ignorePatterns #1210

@nickytonline

Description

@nickytonline

Describe the bug

When vp staged passes files to vp fmt that are all excluded by fmt ignorePatterns in vite.config.ts, vp fmt exits non-zero with "Expected at least one target file" instead of exiting 0.

This happens when a CI bot commits only package-lock.json. The staged config matches it via *.json, passes it to vp fmt, which filters it out via ignorePatterns, then errors because zero files remain.

Config:

staged: {
  "*.{json,md,mdx,css,html,yml,yaml}": ["vp fmt"],
},
fmt: {
  ignorePatterns: ["package-lock.json", ...],
},

Expected: vp fmt exits 0 when all inputs are excluded by its own ignore patterns.
Actual: exits non-zero with "Expected at least one target file".

Reproduction

https://github.com/nickytonline/vp-fmt-repro

Steps to reproduce

  1. Install Vite+: curl -fsSL https://viteplus.dev/install.sh | bash
  2. Clone the https://github.com/nickytonline/vp-fmt-repro repo and run vp install
  3. Make any change to package-lock.json (e.g. add a trailing newline)
  4. Stage and commit:
    git add package-lock.json
    git commit -m "test"
    

System Info

vp v0.1.14
vite-plus v0.1.14
oxfmt v0.42.0
Node.js v22.22.2
npm v11.12.1

Used Package Manager

npm

Logs

See https://github.com/nickytonline/nickytdotco/actions/runs/23727201068/job/69113096665#logs


Run ./bin/pr-blog-posts.sh
  ./bin/pr-blog-posts.sh
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***
Switched to branch 'chore_automated_update_blog_posts_1774842949'
M	package-lock.json
Creating PR "chore (automated): update blog posts" for branch chore_automated_update_blog_posts_1774842949
[STARTED] Backing up original state...
[COMPLETED] Backed up original state in git stash (77fcc62)
[STARTED] Running tasks for staged files...
[STARTED] Config object — 1 file
[STARTED] *.{js,ts,jsx,tsx,astro,mjs,cjs} — 0 files
[STARTED] *.{json,md,mdx,css,html,yml,yaml} — 1 file
[SKIPPED] *.{js,ts,jsx,tsx,astro,mjs,cjs} — no files
[STARTED] vp fmt
[FAILED] vp fmt [FAILED]
[FAILED] vp fmt [FAILED]
[COMPLETED] Running tasks for staged files...
[STARTED] Applying modifications from tasks...
[SKIPPED] Skipped because of errors from tasks.
[STARTED] Reverting to original state because of errors...
[COMPLETED] Reverting to original state because of errors...
[STARTED] Cleaning up temporary files...
[COMPLETED] Cleaning up temporary files...
✖ vp fmt:
Expected at least one target file
VITE+ - pre-commit script failed (code 1)
remote: 
remote: Create a pull request for 'chore_automated_update_blog_posts_1774842949' on GitHub by visiting:        
remote:      https://github.com/nickytonline/nickytdotco/pull/new/chore_automated_update_blog_posts_1774842949        
remote: 
To https://github.com/nickytonline/nickytdotco
 * [new branch]      chore_automated_update_blog_posts_1774842949 -> chore_automated_update_blog_posts_1774842949
pull request create failed: GraphQL: No commits between main and chore_automated_update_blog_posts_1774842949 (createPullRequest)
no pull requests found for branch "chore_automated_update_blog_posts_1774842949"
Error: Process completed with exit code 1.

Validations

Metadata

Metadata

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions