amitsalyan amitsalyan - 3 years ago 115
Node.js Question

Gulp.js Ignoring source Control Files

I have a project structure some thing like:

web
a.html
CVS
folderA
b.html
CVS
c.html


I am trying to use gulp to copy src to dest
However i want to ignore all CVS folders [souce control] in all levels.
Tried gulp-filter or !{dir} at src, nothing works...

Here is my gulpfile.js code for the same:

Doesnt work:

gulp.task('default', function() {
gulp.src([myDir+'/**'])
.pipe(filter(['*', '!'+myDir+'/CVS/**']))
.pipe(gulp.dest(jboss_dir));
});


Nor Does this:

gulp.task('default', function() {
gulp.src([myDir+'/**', '!'+myDir+'/CVS/**'])
.pipe(gulp.dest(jboss_dir));
});

Answer Source

Two issues:

  1. You're only excluding the top level CVS folder. To exclude any folder/subfolder named CVS, you need to use '!' + myDir + '/**/CVS/**'.
  2. CVS/** will select all the contents of a CVS folder, but not the folder itself. If you want to exclude both the folder and its contents, do it explicitly: '!' + myDir + '/**/CVS', '!' + myDir + '/**/CVS/**'.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download