Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell prettier to parse files recursively?

Tags:

I'd like to ask prettier to parse my JavaScript files recursively instead of specifying each folder in which it should check the files.

I'd like to do something like:

prettier --write "all_js_files_except_node_modules_folder"

I don't find much into their documentation. Any suggestions?

Thanks, Paul

like image 550
Paul Avatar asked May 03 '17 15:05

Paul


People also ask

How do I format all files in a directory with Prettier?

From the directory you want to format, run Prettier with --write : prettier --write . This will format the entire directory recursively with Prettier. If you'd rather not install Prettier globally, then you can achieve the same effect with the npx command (the npm package runner):

How do I run a Prettier on a specific file?

Use the prettier command to run Prettier from the command line. To run your locally installed version of Prettier, prefix the command with npx or yarn (if you use Yarn), i.e. npx prettier --help , or yarn prettier --help . To format a file in-place, use --write . (Note: This overwrites your files!)


1 Answers

This issue from a few weeks back seems like it answers your question. TL;DR:

prettier "{,!(node_modules)/**/}*.js" 
like image 157
Joe Clay Avatar answered Oct 06 '22 01:10

Joe Clay