Closed giovannicandido closed 8 years ago
For your purpose, let gulp.src
ignore directories by using glob pattern and options.
(ref. https://github.com/hparra/gulp-rename/issues/59#issuecomment-152194264)
Just to clarify, my task is:
gulp.task('run', function (done) {
return gulp.src(__dirname + '/templates/**') // Note use of __dirname to be relative to generator
.pipe(gulpFilter(filterFiles))
.pipe(template(answers,{
interpolate: /<%=([\s\S]+?)%>/g
})) // Lodash template support
.pipe(rename(function(file){
if(file.basename[0] === '@'){
file.basename = '.' + file.basename.slice(1);
}
// packageName support
var newPackage = answers.packageName.split('.').join('/');
for(var i=0;i<packageReplacements.length;i++){
// startsWith
if(file.dirname.contains(packageReplacements[i])){
file.dirname = file.dirname.replace(packageReplacements[i], newPackage)
}
}
}))
.pipe(gulpFilter(['**','!server/src/**/info','!server/src/**/info/**'])) // Work around to remove the empty packages
.pipe(conflict('./')) // Confirms overwrites on file conflicts
.pipe(gulp.dest('./')) // Without __dirname here = relative to cwd
.pipe(install()) // Run `bower install` and/or `npm install` if necessary
});
The point of interest is all directories with the pattern /info/atende/touch/ are renamed to /user/provided/directories/, but after the rename the directory is still on the stream (empty) and therefore gulp.dest creates then. So, another filter takes place after the rename and remove the renamed folders from the stream.
Is there a better way instead of using a filter after de rename? Feel like a hack but a can live with that :-)
Is there a better way instead of using a filter
Just what I said in https://github.com/hparra/gulp-rename/issues/65#issuecomment-184060339. The simplest way is using glob's nodir
option.
Further questions go to StackOverflow. http://stackoverflow.com/questions/tagged/gulp-rename
gulp.dest keeps creating the original renamed empty directory's
Suppose I have:
The destination will have the original directories empty, and the renamed ones with the files
I think the expected behaviour is to remove then