Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming a directory in gulp

I'm using gulp-rename to rename a directory as follows:

gulp.task('vendor-rename-pre', function() {
  return gulp.src('src/vendor')
    .pipe(rename('vendor-dev'))
    .pipe(gulp.dest('src'));
});

However, it essentially ends up creating a new, empty directory called vendor-dev instead of renaming vendor. vendor is left as is.

So, how can I actually rename a directory using gulp?

like image 208
Gezim Avatar asked Mar 10 '26 05:03

Gezim


1 Answers

There's nothing Gulp-specific about renaming a file on disk. You can just use the standard Node.js fs.rename() function:

var fs = require('fs');

gulp.task('vendor-rename-pre', function(done) {
  fs.rename('src/vendor', 'src/vendor-dev', function (err) {
    if (err) {
      throw err;
    }
    done();
  });
});
like image 62
Sven Schoenung Avatar answered Mar 13 '26 13:03

Sven Schoenung