-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for file path wildcards #362
Comments
Regarding globs – it all depends on what your shell supports. In particular, if it supports the If a shell supports In bash, you must make sure to enable the "globstar" option (and make sure to run a version of bash that has that option).
Since there are so many shells and so many versions, it's difficult to get globbing right. To make things worse, the default shell in many operating system doesn't support the {
"scripts": {
"prettier": "prettier src/**/*.js"
}
} The above is not a good cross-platform solution. Therefore, it is common among Node.js CLI tools to incorprate their own globbing support, allowing to write the above example as: {
"scripts": {
"prettier": "prettier 'src/**/*.js'"
}
} Note the added single quotes above. They make sure that the shell does not try to expand the globs. Instead, the exact string |
Fixes prettier#145. Fixes prettier#362.
I think we should change the README to avoid using the glob expansion since it doesn't work in bash. We can replace it find I agree that passing globs as strings and having prettier handle them seem like a great solution. |
Thanks for your explanations but none of the above patterns works in Windows. Can you give me a hint what should I do to introduce all js files in src directory to prettier? |
@metacoding If you wrap your pattern in quotes, Prettier will execute the pattern for you in a cross-platform way.
I believe there is some information in the docs about this, but I'm not sure where it is at the moment. (apologies). |
Lets say we have this structure
Using macOS 10.12.2 and node v7.4.0 - this command
prettier --write src/**/*.js
will ignore content inside ofbar
directory.After some research I found that
process.argv
works like that and there are no workaround. (At least I didn't find any).And I made my own tool using
glob
and it worked how I expected.I know that prettier will Resist adding configuration (#40)
And idea about
.prettierrc
was already declined (#154)But what about adding
.prettierrc
to add current available options only ?Or add
--source=src/**/*.js
parameter to define which files should be prettified.And use tools like
glob
to list all available files fromsource
wildcards.I will be happy to add PR if you're agree with this proposal.
The text was updated successfully, but these errors were encountered: