简体   繁体   中英

gulp-rename makes copies, but does not replace

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM