Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TODO: Count number of changes... only create PR if > 0
- // TODO: Only change version if new number is greater. Will need semver lib.
- target.versionReplace = function() {
- var currentDeps = fs.readFileSync('C:\\Users\\stfrance\\Desktop\\tempdeps.xml', "utf8");
- var newDeps = fs.readFileSync('C:\\Users\\stfrance\\Downloads\\IndividualNuGetPackages\\IndividualNuGetPackages\\unified_deps.xml', "utf8");
- var currentDepsArr = currentDeps.split('\n');
- var newDepsArr = newDeps.split('\n');
- var newDepsDict = {};
- newDepsArr.forEach(function (newDep) {
- // add to dictionary
- var depDetails = newDep.split("\"");
- //console.log(JSON.stringify(depDetails));
- var name = depDetails[1];
- var version = depDetails[3];
- //console.log(name + ' ' + version);
- newDepsDict[name] = version;
- });
- var updatedDeps = [];
- currentDepsArr.forEach(function (currentDep) {
- var depDetails = currentDep.split("\"");
- var name = depDetails[1];
- var version = depDetails[3];
- // find if there is a match in new
- if (newDepsDict[name]) {
- // update the version
- depDetails[3] = newDepsDict[name];
- updatedDeps.push(depDetails.join('\"'));
- } else {
- updatedDeps.push(currentDep);
- }
- });
- // list new ones that arent in current
- newDepsArr.forEach(function (newDep) {
- // add to dictionary
- var depDetails = newDep.split("\"");
- //console.log(JSON.stringify(depDetails));
- var name = depDetails[1];
- var version = depDetails[3];
- var currentContainsNew = false;
- currentDepsArr.forEach(function (currentDep) {
- var depDetails = currentDep.split("\"");
- var currName = depDetails[1];
- if (currName === name) {
- currentContainsNew = true;
- }
- });
- if (!currentContainsNew) {
- console.log(name);
- }
- });
- // write it as a new file where currentDeps is
- fs.writeFileSync("C:\\Users\\stfrance\\Desktop\\NEW.txt", updatedDeps.join("\n"));
- console.log('Done.');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement