UNPKG

steam-client

Version:

SteamClient from node-steam with proper versioning and more features

38 lines (31 loc) 1.18 kB
// This file is run by npm prior to the package being published to the registry // Update the CM list require('http').get("http://api.steampowered.com/ISteamDirectory/GetCMList/v1/?format=json&cellid=0", function(res) { var data = ''; res.on('data', function(chunk) { data += chunk; }); res.on('end', function() { var json = JSON.parse(data); if (!json.response || json.response.result != 1) { throw new Error("Cannot get CM list"); } var servers = json.response.serverlist.map(function (server) { var parts = server.split(':'); return { "host": parts[0], "port": parseInt(parts[1], 10) }; }); var websockets = json.response.serverlist_websockets.map(function(server) { var parts = server.split(':'); return { "host": parts[0], "port": parseInt(parts[1]) }; }); websockets.sort(function(a, b) { return a.host < b.host ? -1 : 1; }); require('fs').writeFileSync(__dirname + '/../resources/servers.json', JSON.stringify(servers, null, "\t")); require('fs').writeFileSync(__dirname + '/../resources/servers_websocket.json', JSON.stringify(websockets, null, "\t")); }); });