Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude a folder from glob pattern matching

Using Prettier to format js code. Prettier seems to be using globby under the hood.

I tried the following:

$ prettier './**/*.{js, css}' '!assets/**'
$ prettier './**/*.{js, css}' '!(assets/**)'
$ prettier './**/*.{js, css}' '!assets/**/*.*'
$ prettier './**/*.{js, css}' '!(assets/**/*.*)'
$ prettier './**/*.{js, css}' 'assets/**/!*.*'

And in all cases, files in the assets folder were included.

What's the correct way to do this ?

like image 727
Michael Avatar asked Sep 07 '25 00:09

Michael


1 Answers

You can now exclude directories with the ! character. For example this command would format all .js and .css files in-place, excluding anything in the assets directory.

"prettier --write **/*.{js, css} !assets/**"
like image 187
Jelefra Avatar answered Sep 08 '25 22:09

Jelefra