mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
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:
1 parent
ca0281ae58
commit
66c0238a3d
2 files changed
+5
-4
No files matched your search
@@ -8,7 +8,6 @@ const syncRequest = require('sync-request');
|
|||||||
const request = require("request");
|
const request = require("request");
|
||||||
const ncp = require('ncp').ncp;
|
const ncp = require('ncp').ncp;
|
||||||
const Rcon = require('rcon-client-fork').Rcon;
|
const Rcon = require('rcon-client-fork').Rcon;
|
||||||
const _ = require('underscore');
|
|
||||||
const deepmerge = require("deepmerge");
|
const deepmerge = require("deepmerge");
|
||||||
const getMac = require('getmac').getMac;
|
const getMac = require('getmac').getMac;
|
||||||
const rmdirSync = require('rmdir-sync');
|
const rmdirSync = require('rmdir-sync');
|
||||||
@@ -563,8 +562,11 @@ write-data=${ path.resolve(config.instanceDirectory, instance) }\r\n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure instancemanagement only ever runs once
|
// ensure instancemanagement only ever runs once
|
||||||
_.once(instanceManagement);
|
var _instanceInitialized;
|
||||||
async function instanceManagement(instanceconfig) {
|
async function instanceManagement(instanceconfig) {
|
||||||
|
if (_instanceInitialized) return;
|
||||||
|
_instanceInitialized = true;
|
||||||
|
|
||||||
console.log("Started instanceManagement();");
|
console.log("Started instanceManagement();");
|
||||||
|
|
||||||
/* Open websocket connection to master */
|
/* Open websocket connection to master */
|
||||||
|
|||||||
+1
-2
@@ -63,8 +63,7 @@
|
|||||||
"socket.io-prometheus": "^0.2.1",
|
"socket.io-prometheus": "^0.2.1",
|
||||||
"sync-request": "^4.0.1",
|
"sync-request": "^4.0.1",
|
||||||
"tail": "^2.0.2",
|
"tail": "^2.0.2",
|
||||||
"typescript-collections": "^1.3.2",
|
"typescript-collections": "^1.3.2"
|
||||||
"underscore": "^1.8.3"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"html5-validator": "^1.0.7",
|
"html5-validator": "^1.0.7",
|
||||||
|
|||||||
Reference in new issue
Block a user