I'm trying to do in my opinion a simple task but can't figure it out. Can't find it on google or here. Maybe i'm doing it completely wrong.
I need to change a property in a json file with gulp 4. To get the new value of the property I have another task or pipe (I don't care :-)) and want to pass it along.
Also, how to pass variable from command line? so in example: gulp release -branchname "foobar"
How can I do this. I know there are similar question here but nothing is working for me...
    var gulp = require('gulp');
var git = require('gulp-git');
var jeditor = require("gulp-json-editor");
var paths = {
    manifest: "vss-extension.json"
}
function getBranchName(){
    console.log("Get the current branch name");
    return git.revParse({args:'--abbrev-ref HEAD'}, function (err, branch) {
        console.log('current git branch: ' + branch);
        var currentBranch = branch;
        return currentBranch;
    });
    // console.log("Current branch is: "+ branchName);
    // return branchName;
}
function updateExtensionManifestVersion(foo){
    var x = 10;
    gulp.src(paths.manifest)
    .pipe(jeditor(function(json) {
        console.log("Append current branchname " + currentBranch + " to extension manifest id");
        var currentId = json.id;
        console.log("Current manifest id: "+ currentId);
        // var branchName = git.revParse({args:'--abbrev-ref HEAD'}, function (err, branch) {
        //     console.log('current git branch: ' + branch);
        //     return branch;
        // });
        // console.log(branchName.branch);
        var newId = currentId + "-" + branchName;
        console.log("New manifest id: " + newId);
        json.id = newId;
        return json;
    }))
    .pipe(gulp.dest(paths.manifest));
}
gulp.task('release', gulp.series(getBranchName, updateExtensionManifestVersion, function(done) {
    console.log("release is done");
    done();
}));
 
    