Reputation: 7318
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?
Upvotes: 2
Views: 5429
Reputation: 16660
Just to answer your question you can do below to use gulp-rename
to rename the file
gulp.task('vendor-rename-pre', function () {
return gulp.src("./app/vendor")
.pipe(rename("./vendor-dev"))
.pipe(gulp.dest("./app"));
});
The only caveat here is that the old file will remain in the same location
Upvotes: 1
Reputation: 30564
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();
});
});
Upvotes: 11