forked from joshuaferrara/node-csgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protoUpdate.js
41 lines (34 loc) · 1.7 KB
/
protoUpdate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var https = require("https");
var fs = require("fs");
var url = require("url");
var path = require("path");
var protos = [
"https://raw.githubusercontent.com/SteamDatabase/GameTracking/master/Protobufs/csgo/base_gcmessages.proto",
"https://raw.githubusercontent.com/SteamDatabase/GameTracking/master/Protobufs/csgo/cstrike15_gcmessages.proto",
"https://raw.githubusercontent.com/SteamDatabase/GameTracking/master/Protobufs/csgo/gcsdk_gcmessages.proto",
"https://raw.githubusercontent.com/SteamDatabase/GameTracking/master/Protobufs/csgo/steammessages.proto",
"https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/steammessages_clientserver.proto",
"https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/steammessages_clientserver_2.proto",
"https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/steammessages_base.proto",
"https://raw.githubusercontent.com/SteamRE/SteamKit/master/Resources/Protobufs/steamclient/encrypted_app_ticket.proto"
];
function download(downloadUrl) {
var fileName = path.basename(url.parse(downloadUrl).pathname);
console.log("\tDownloading " + fileName);
var file = fs.createWriteStream(__dirname + "/protos/" + fileName);
var request = https.get(downloadUrl, function(response) {
response.pipe(file);
});
}
console.log("Updating protobufs...");
var oldProtos = fs.readdirSync(__dirname + "/protos/");
oldProtos.forEach(function(fileName) {
if (fileName.indexOf(".proto") != -1) {
console.log("\tRemoving old protobuf file: " + fileName);
fs.unlinkSync(__dirname + "/protos/" + fileName);
}
});
protos.forEach(function(url) {
download(url);
});
console.log("Update complete!");