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.
This commit is contained in:
Hornwitser committed 2019-08-07 10:18:14 +02:00
1 parent ca0281ae58
commit 66c0238a3d
2 files changed
+5 -4

No files matched your search

+4 -2
View File
@@ -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 */