Error thrown on no file matching glob in 2.0.x
See original GitHub issueEnvironments:
- Prettier Version: 2.0.2
- Running Prettier via: CLI
- Runtime: Node 12
- Operating System: OSX Cataline
Expected behavior:
Non-matching glob does not throw any error as in 1.x
Actual behavior:
Non-matching glob throws an error
We use the same prettier-config and prettier cli invocation for all of our repos, regardless of whether they currently contain files of a particular type. This worked fine in 1.x but in 2.x this causes an error when a glob matches no files.
A warning would be better.
npx prettier --write \"{apps,libs}/**/*.{js,ts,css,scss,html,json,yaml,yml,md}\"
...
[error] No files matching the pattern were found: "*.yaml".
[error] No files matching the pattern were found: "*.yml".
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! ccxp-client@0.0.1 prettier-all: `npx prettier --write "{apps,libs}/**/*.{js,ts,css,scss,html,json,yaml,yml,md}" && npx prettier --write *.{json,js,md,yaml,yml}`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the ccxp-client@0.0.1 prettier-all script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/pete.burkindine/.npm/_logs/2020-03-24T16_22_15_545Z-debug.log
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How can I suppress the "No files matching the pattern ...
If no JS files exist, it's currently throwing an error. I'd prefer if it'd succeeded when no JS files exist. Is this possible?...
Read more >Command Line Interface - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >micromatch - npm
Similar to the failglob behavior in Bash, throws an error when no matches are found. Based on the bash option of the same...
Read more >Mocha - the fun, simple, flexible JavaScript test framework
If you use callback-based async tests, Mocha will throw an error if done() is called ... return -1 when the value is not...
Read more >Configuring Jest
Thresholds for globs are applied to all files matching the glob. If the file specified by path is not found, an error is...
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 Free
Top 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
Ah! We’re making this too hard 😄
The issue is actually the second part of the invocation (
npx prettier@2.0.2 --write *.{json,js,md,yaml,yml}
); wrapping the glob there in quotes solved the problem (npx prettier@2.0.2 --write \"*.{json,js,md,yaml,yml}\"
)I think the CLI flag is still a good idea, though
Closing this in favor of https://github.com/prettier/prettier/issues/8233