Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use files with multiple extensions with Prettier?

I have following Prettier commands:

prettier --parser typescript --write ./src/**/*.ts prettier --parser typescript --write ./src/**/*.tsx 

I would like to merge them to single one - use some king of regex to listen (write) on both .ts and also .tsx extensions.

Something like:

prettier --write ./src/**/*.ts(x?) 
like image 748
Jurosh Avatar asked Jun 23 '17 14:06

Jurosh


2 Answers

Just found solution. Following command will target both ts and tsx:

prettier --write "./src/**/*.{ts,tsx}" 

Prettier is using Glob syntax which is syntax similar to Regex, used in shell.

See GLOB syntax details: https://github.com/isaacs/node-glob/blob/master/README.md#glob-primer

like image 111
Jurosh Avatar answered Sep 20 '22 15:09

Jurosh


If you want to run prettier command on multiple paths with multiple extensions use the following command:

prettier --write "src/**/*.{ts,tsx,js,jsx}" "pages/**/*.{ts,tsx,js,jsx}" "server/**/*.js" 
like image 33
ziishaned Avatar answered Sep 19 '22 15:09

ziishaned