Skip to content

Commit

Permalink
Merge pull request #56 from aitnitishshelage/script-update
Browse files Browse the repository at this point in the history
Script updated for GVL changes
  • Loading branch information
iabmayank authored Aug 17, 2022
2 parents 9ff36b5 + d634eae commit 0a5d811
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion update-vendor-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ async function updateGVLData(){
console.log(`writing file vendor-list-v${counter}.json`);
await downloadFile(`${latestVersionURL}/archives/vendor-list-v${counter}.json`, `./docs/vendorlist/archives/vendor-list-v${counter}.json`);
}
await downloadFile(`${latestVersionURL}/archives/vendor-list-v${latestVersion}.json`, `./docs/vendorlist/vendor-list.json`);
console.log(`updating file vendor-list.json`);
await removeOldFile(`./docs/vendorlist/vendor-list.json`);
await updateVendorList(`./docs/vendorlist/vendor-list.json`, `archives/vendor-list-v${latestVersion}.json`);
}
}

Expand All @@ -56,4 +58,23 @@ async function downloadFile(fileUrl, outputLocationPath) {
});
}

async function removeOldFile(path){
return Fs.unlink(path,function(err){
if(err) return console.log(err);
console.log('file deleted successfully');
});
}

async function updateVendorList(path, content){
return Fs.writeFile(path, content, (err) => {
if (err)
console.log(err);
else {
console.log("File written successfully\n");
console.log("The written has the following contents:");
console.log(Fs.readFileSync(path, "utf8"));
}
});
}

updateGVLData();

0 comments on commit 0a5d811

Please sign in to comment.