Reputation: 831
I would like to copy a folder to another destination and rename a certain file in the same process.
gulp.task('deploy', function () {
gulp.src(['xxx/**/*']).pipe(gulp.dest('yyy'));
});
I am able to copy the folder over just fine but how would I go about renaming the file?
Source folder structure:
- xxx (root)
- scripts
- config
- app.config.local.js (would like to rename this file as app.config.js)
- app.config.dev.js
Upvotes: 0
Views: 728
Reputation: 30564
You can use the gulp-rename
plugin to rename files and the gulp-if
plugin to make sure the renaming is only applied to one particular file:
var gulp = require('gulp');
var rename = require('gulp-rename');
var _if = require('gulp-if');
gulp.task('deploy', function() {
return gulp.src(['xxx/**/*'])
.pipe(_if('**/app.config.local.js', rename({basename:'app.config'})))
.pipe(gulp.dest('yyy'));
});
Upvotes: 3