Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include multiple file extensions with 'glob.sync' in NodeJS?

Can anyone please suggest how to add multiple file extensions with the glob.sync method.

Something like:

const glob = require('glob');
let files = glob.sync(path + '**/*.(html|xhtml)');

Thank you :)

like image 375
asishkhuntia Avatar asked Mar 30 '17 12:03

asishkhuntia


1 Answers

You can use this (which most shells support as well):

glob.sync(path + '**/*.{html,xhtml}')

Or one of these:

glob.sync(path + '**/*.+(html|xhtml)')
glob.sync(path + '**/*.@(html|xhtml)')
like image 139
robertklep Avatar answered Sep 21 '22 13:09

robertklep