question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error thrown on no file matching glob in 2.0.x

See original GitHub issue

Environments:

  • 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
pburkindinecommented, Mar 24, 2020

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

0reactions
thorn0commented, May 6, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found