简体   繁体   中英

Recursively select file in mac - need to prettier all files in directory

I am following this medium post .

Running the command prettier --write ./src/**/*.{js,jsx,scss} works perfectly fine on windows machine.

However, when using Mac machine, this command doesn't go recursively on files that present on sub-folders.

What is the difference between windows and mac on this?

You could use find with -exec, like so

find src -iname \*.js -or -iname \*.jsx -exec prettier --write {} \;

The arguments:

  • src: the directory (be careful to not run on .git, node_modules, etc
  • -iname: case insensitive name
  • -or: or, to chain options together, in this case iname
  • -exec: execute the following command for every item found. It replaces {} with the item found. Exec needs \\; at the end to know when your command is over.

Before you execute it, you could prepend echo to preview what commands will be running, like so

find src -iname \*.js -or -iname \*.jsx -exec echo prettier --write {} \;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM