If I do this:
var gulp = require('gulp');
var replace = require('gulp-replace');
var rename = require('gulp-rename');
gulp.task('TaskExample', function ReplaceExampleFileTokens() {
return gulp.src('./src/' + 'ExampleFileTokens.config')
.pipe(replace('#{String}#', 'Hello World'))
.pipe(rename('ExampleFile.config'))
.pipe(gulp.dest('./dest'));
});
I will:
replace the token in
ExampleFileTokens.configthenrename it to
ExampleFile.configandfinally deposit it in
'./dest'.
My questions are the following:
How would you check that
#{String}#exists inExampleFileTokens.configwithout using gulp.dest if the token doesn't exist?I know I could search the file in javascript with the token, but is there a way with maybe
gulp-replace, since it's already searching and replacing my tokens?
I don't think there is a way to have gulp-replace do all the work you want. It is troublesome to set a conditional within a stream.
You can do it easily enough with a filter though (gulp-filter.