I have a gulp task similar to the following. I am trying to loop through and append a string to the page and also concatenate a corresponding file.
gulp.task('loop', function() {
for(i =0; i < 10; i++) {
gulp.src('./build/ross/templates/pages/_page_home.liquid')
.pipe(plugins.insert.append('Loop ' + i))
// real example has concat here
.pipe(plugins.addSrc('./src/page/_page' + i + '.liquid'))
.pipe(plugins.concat('_page_home.liquid'))
.pipe(gulp.dest('./build/ross/templates/pages/'));
}
});
Expected output would be something like
Loop 1
// _page1.liquid contents
Loop 2
// _page2.liquid contents
Loop 3
// _page3.liquid contents
and so on...
Actual output appears more like
// Original Page Contents here
Loop 9
// _page9.liquid contents
I did a fs.readFile
on the original file in the loop and outputted the data and it is only outputting the original page contents and not the concatenated file or the string I'm trying to append.
I also did a console.log(i)
inside and it's showing the proper numbers 1,2,3,4,5,6,7,8,9
. I wonder if this has something to do with the gulp.src()
Update: Sometimes it appears that the output contents will actually have parts of the _page#.liquid contents. It is a bit inconsistent.
Is there a better way to do this with gulp or am I just doing something wrong?