gulp/versioning.js
function createReplaceVersion(inPath, version, opts = {}) {
    if (!inPath) {
        throw new Error('Input path(s) argument is required');
    }

    if (!version) {
        throw new Error('Version argument is required');
    }

    const dropV = !!opts.dropV;
    const versionRegex = dropV ? /[0-9]+\.[0-9]+\.[0-9]+\b/g : /v[0-9]+\.[0-9]+\.[0-9]+\b/g;
    const versionString = dropV ? version : `v${version}`;

    return function updateVersions() {
        return gulp.src(inPath)
            .pipe(replace(versionRegex, versionString))
            .pipe(gulp.dest(file => file.base));
    };
}
function createReplaceVersion(inPath, version, opts = {}) {
    if (!inPath) {
        throw new Error('Input path(s) argument is required');
    }

    if (!version) {
        throw new Error('Version argument is required');
    }

    const dropV = !!opts.dropV;
    const versionRegex = dropV ? /[0-9]+\.[0-9]+\.[0-9]+\b/g : /v[0-9]+\.[0-9]+\.[0-9]+\b/g;
    const versionString = dropV ? version : `v${version}`;

    return function updateVersions() {
        return gulp.src(inPath)
            .pipe(replace(versionRegex, versionString))
            .pipe(gulp.dest(file => file.base));
    };
}
function createReplaceVersion ( inPath , version , opts = { } ) { if ( ! inPath ) { throw new Error ( 'Input path(s) argument is required' ) ; } if ( ! version ) { throw new Error ( 'Version argument is required' ) ; } const dropV = ! ! opts . dropV ; const versionRegex = dropV ? / [0-9]+\.[0-9]+\.[0-9]+\b / g : / v[0-9]+\.[0-9]+\.[0-9]+\b / g ; const versionString = dropV ? version : ` ${ version } ` ; return function updateVersions ( ) { return gulp . src ( inPath ) . pipe ( replace ( versionRegex , versionString ) ) . pipe ( gulp . dest ( file => file . base ) ) ; } ; }
Higher order function to create gulp function that replaces instances of the version number
with the new version.
@param  {string|string[]} inPath The globs to the files that need to be searched
@param  {string} version The version to update to without a leading 'v'
@param  {Object} [opts={}] Extra options for replace
@param  {string} [opts.dropV=false] Optional flag to search/replace 'X.Y.Z' instead of 'vX.Y.Z'
@return {function} Function that can be used as a gulp task
Higher order function to create gulp function that replaces instances of the version number with the new version .