From 66c0238a3d29d5ef4c047e33e11ab3d4847f1eb5 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 3 Aug 2019 19:01:26 +0200 Subject: [PATCH] Remove undescore A 50 kb library is not needed to make a function run once, especially not when it doesn't work. _.once does not modify the function passed to it to only run once it returns a new function that only runs once. Since the result of once was discarded, it had no effect. Remove underscore and implement instanceManagement running once properly with 3 lines of code. --- client.js | 6 ++++-- package.json | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client.js b/client.js index 67b8bd04..6434ba22 100644 --- a/client.js +++ b/client.js @@ -8,7 +8,6 @@ const syncRequest = require('sync-request'); const request = require("request"); const ncp = require('ncp').ncp; const Rcon = require('rcon-client-fork').Rcon; -const _ = require('underscore'); const deepmerge = require("deepmerge"); const getMac = require('getmac').getMac; const rmdirSync = require('rmdir-sync'); @@ -563,8 +562,11 @@ write-data=${ path.resolve(config.instanceDirectory, instance) }\r\n } // ensure instancemanagement only ever runs once -_.once(instanceManagement); +var _instanceInitialized; async function instanceManagement(instanceconfig) { + if (_instanceInitialized) return; + _instanceInitialized = true; + console.log("Started instanceManagement();"); /* Open websocket connection to master */ diff --git a/package.json b/package.json index baa0a308..da2dd9ae 100644 --- a/package.json +++ b/package.json @@ -63,8 +63,7 @@ "socket.io-prometheus": "^0.2.1", "sync-request": "^4.0.1", "tail": "^2.0.2", - "typescript-collections": "^1.3.2", - "underscore": "^1.8.3" + "typescript-collections": "^1.3.2" }, "devDependencies": { "html5-validator": "^1.0.7",