Looking to update the version number in a JavaScript file (myConstantsFile.js
) with a new string. Currently, the version number is "01.11.15" and appears like this in myConstantsFile.js
along with other constants:
.constant('productVersion', '1.11.15');
Currently, the task involves:
gulp.task('increment-version', function(){
gulp.src(['./somedir/myConstantsFile.js'])
.pipe(replace(/'productVersion', '(.*)'/g, '99.99.99'))
.pipe(gulp.dest('./somedir/'));
});
Instead of using direct incrementation code, I am utilizing a constant value.
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;
Specifically, I require:
- A method to select the current version number in the file via regex.
- The location in the code block where the logic can be inserted to increment the number and generate the updated string.