Added optional parameter to filter directory by regex

Added this to allow us to ignore node_modules for performance reasons, made it generic as it may be more useful to others this way.  Can't get the tests to run as they are, so haven't written a test for this - shout if you want me to have another go at it.