これらのhtmlファイルを読み、変数を抽出する必要があります。
var fs = require('fs');
const index1 = 'index.html';
const index2 = 'index-two.html';
gulp.task("move-html", function() {
var firstFile;
var secondFile;
var var1;
var var2;
var re = /@@variable\s*=\s*('.*')/ig;
firstFile= fs.readFileSync(index1, 'utf8');
secondFile = fs.readFileSync(index2 'utf8');
// now firstFile and secondFile are just strings that you can manipulate to get that @@variable.
var1 = re.exec(firstFile)[1];
var2 = re.exec(secondFile)[1];
// var1 and var2 should now have your @@variable values from the two html files.
if (var1 === 'free') {
gulp.src(['index.html'])
.pipe(gulp.dest('build/free'));
}
else if (var1 === 'pro') {
gulp.src(['index.html'])
.pipe(gulp.dest('build/pro'));
}
if (var2 === 'free') {
gulp.src(['index-two.html'])
.pipe(gulp.dest('build/free'));
}
else if (var2 === 'pro') {
gulp.src(['index-two.html'])
.pipe(gulp.dest('build/pro'));
}
});
この未テストの擬似コードを考えてみましょう。それの一部は、おそらく動作しませんが、それはあなたを開始する必要があります。