I would like to replace a string indicating version number in a javascript file (myConstantsFile.js
), with another string. So, for example, my version number looks like this: "01.11.15", written like this in myConstantsFile.js
with other constants:
.constant('productVersion', '1.11.15');
Right now, my task looks like this:
gulp.task('increment-version', function(){
gulp.src(['./somedir/myConstantsFile.js'])
.pipe(replace(/'productVersion', '(.*)'/g, '99.99.99'))
.pipe(gulp.dest('./somedir/'));
});
As you can see, I am using a constant, not running incrementation code, which would look like this:
var numberString = '0.0.1';
var versionParts = numberString.split('.');
var vArray = {
vMajor : versionParts[0],
vMinor : versionParts[1],
vPatch : versionParts[2]
}
vArray.vPatch = parseFloat(vArray.vPatch) + 1;
var periodString = ".";
var newVersionNumberString = vArray.vMajor + periodString +
vArray.vMinor+ periodString +
vArray.vPatch;
I need:
- A way to select the current version number via regex via the file.
- To know where I can put the logic in the last code block to increment the number and build the new string.