Ad

Gulp-rename Makes Copies, But Does Not Replace

- 1 answer

Im trying to rename a batch of files.

gulp.task('rename', ['jade'], function() {
  gulp.src("public/build/*.html")
    .pipe(rename(function (path) {
      path.dirname += "/";
      path.basename += "";
      path.extname = ""
    }))
    .pipe(gulp.dest("public/build"));
  gulp.src("public/build/story/*.html")
    .pipe(rename(function (path) {
      path.dirname += "/";
      path.basename += "";
      path.extname = ""
    }))
    .pipe(gulp.dest('public/build/story'));
  gulp.src("public/build/work/*.html")
    .pipe(rename(function (path) {
      path.dirname += "/";
      path.basename += "";
      path.extname = ""
    }))
    .pipe(gulp.dest('public/build/work'));
});

This method finds the files I want to change and does the job, but it makes a entirely new files, and does not replace the old file. So im left with doubles of my batch, is there anything i should be adding to have this not happen?

Ad

Answer

I don't believe gulp-rename is supposed to replace your currently files, I am pretty sure it's supposed to just rename them and put them in a different directory. It's used when preparing an application for distribution. If you want to look into also removing files I would checkout out gulp-rimraf. github.com/robrich/gulp-rimraf

Ad
source: stackoverflow.com
Ad