davglass / cpr

Nodejs cp -R
Other
79 stars 80 forks source link

regex in filter option not working as expected with directories. #32

Closed digitalmouse closed 8 years ago

digitalmouse commented 8 years ago

Greetings! I have the following code that is trying to ignore CVS directories, but the last 5 variations of regex I tried do not appear to work as expected, but I've tested the regex online and in other code, so the format should be ok. Any tips on what I might be doing wrong are appreciated.

` code snippet

cpr('./public', 'build/public/', {
  deleteFirst: true,
  overwrite: true,
  confirm: true,
  filter: '^((?!CVS).)*$'
}, function (err) {
 if (err) {
  console.log(colors.red.bold('Something went wrong during copy: '), err.stack);
  return console.error(err);
 }
 console.log(colors.blue.bold('...copied ./public to build directory!'));
});

`

digitalmouse commented 8 years ago

discovered my mistake! no quotes around the regex as if it were a string, but instead use forward slashes: /(regex here)/

problem solved!