Fix missing semicolons

Ensure all statements end with a semicolon.
This commit is contained in:
Hornwitser committed 2020-06-17 20:53:18 +02:00
1 parent 34aaeee354
commit 29f066a191
56 files changed
+242 -242

No files matched your search

+12 -12
View File
@@ -73,7 +73,7 @@ class Config extends events.EventEmitter {
super();
if (!this.constructor._finalized) {
throw new Error(`Cannot instantiate incomplete Config class ${this.constructor.name}`)
throw new Error(`Cannot instantiate incomplete Config class ${this.constructor.name}`);
}
this._groups = new Map();
@@ -177,7 +177,7 @@ class Config extends events.EventEmitter {
*/
group(name) {
if (!this._initialized) {
throw new Error(`${this.constructor.name} instance is uninitialized`)
throw new Error(`${this.constructor.name} instance is uninitialized`);
}
let group = this._groups.get(name);
if (!group) {
@@ -263,7 +263,7 @@ class ConfigGroup {
*/
constructor(serializedGroup) {
if (!this.constructor._finalized) {
throw new Error(`Cannot instantiate incomplete ConfigGroup class ${this.constructor.name}`)
throw new Error(`Cannot instantiate incomplete ConfigGroup class ${this.constructor.name}`);
}
this._fields = new Map();
@@ -287,7 +287,7 @@ class ConfigGroup {
let value = null;
if (typeof def.initial_value === "function") {
value = await def.initial_value()
value = await def.initial_value();
} else if (def.initial_value !== undefined) {
value = def.initial_value;
@@ -368,14 +368,14 @@ class ConfigGroup {
try {
value = JSON.parse(value);
} catch (err) {
throw new InvalidValue(`Error parsing value for ${name}: ${err.message}`)
throw new InvalidValue(`Error parsing value for ${name}: ${err.message}`);
}
}
}
if (value === null) {
if (!def.optional) {
throw new InvalidValue(`Field ${name} cannot be null`)
throw new InvalidValue(`Field ${name} cannot be null`);
}
} else {
@@ -540,11 +540,11 @@ class ConfigGroup {
*/
static define(item) {
if (this._finalized) {
throw new Error(`Cannot define field for ConfigGroup class ${this.name} after it has been finalized`)
throw new Error(`Cannot define field for ConfigGroup class ${this.name} after it has been finalized`);
}
if (basicType(this.groupName) !== "string") {
throw new Error(`Expected ConfigGroup class ${this.name} to have the groupName property set to a string`)
throw new Error(`Expected ConfigGroup class ${this.name} to have the groupName property set to a string`);
}
this._initSubclass();
@@ -556,7 +556,7 @@ class ConfigGroup {
if (!itemKeys.includes(prop)) {
throw new Error(`${prop} is required when defining an field`);
}
})
});
// Validate properties
let validTypes = ["boolean", "string", "number", "object"];
@@ -618,7 +618,7 @@ class ConfigGroup {
let computed = Object.assign({
optional: false,
fullName: `${this.groupName}.${item.name}`,
}, item)
}, item);
if (!computed.optional && computed.initial_value === undefined) {
throw new Error(`Non-optional field ${item.name} needs an initial_value`);
@@ -632,7 +632,7 @@ class ConfigGroup {
*/
static finalize() {
if (basicType(this.groupName) !== "string") {
throw new Error(`Expected ConfigGroup class ${this.name} to have the groupName property set to a string`)
throw new Error(`Expected ConfigGroup class ${this.name} to have the groupName property set to a string`);
}
this._initSubclass();
@@ -672,4 +672,4 @@ module.exports = {
Config,
ConfigGroup,
PluginConfigGroup,
}
};
+3 -3
View File
@@ -15,7 +15,7 @@ const classes = require("./classes");
* @memberof module:lib/config
*/
class MasterGroup extends classes.ConfigGroup { }
MasterGroup.groupName = "master"
MasterGroup.groupName = "master";
MasterGroup.define({
name: "database_directory",
title: "Database directory",
@@ -189,7 +189,7 @@ SlaveConfig.registerGroup(SlaveGroup);
* @memberof module:lib/config
*/
class InstanceGroup extends classes.ConfigGroup { }
InstanceGroup.groupName = "instance"
InstanceGroup.groupName = "instance";
InstanceGroup.define({
name: "name",
type: "string",
@@ -438,4 +438,4 @@ module.exports = {
finalizeConfigs,
configCommand,
handleConfigCommand,
}
};
+1 -1
View File
@@ -6,4 +6,4 @@
module.exports = {
...require("./classes"),
...require("./definitions"),
}
};
+2 -2
View File
@@ -232,7 +232,7 @@ class ItemDatabase {
checkName(name);
if (!this._items.has(name)) {
return 0
return 0;
}
return this._items.get(name);
@@ -287,4 +287,4 @@ module.exports = {
loadJsonArrayAsMap,
saveMapAsJsonArray,
ItemDatabase,
}
};
+1 -1
View File
@@ -71,4 +71,4 @@ module.exports = {
StartupError,
EnvironmentError,
PluginError,
}
};
+1 -1
View File
@@ -21,7 +21,7 @@ const buildMod = require("../../build-mod");
*/
async function generateExportMod(server) {
let dependencies = [];
let splitter = /^(.*)_(\d+\.\d+\.\d+)(\.zip)?$/
let splitter = /^(.*)_(\d+\.\d+\.\d+)(\.zip)?$/;
for (let entry of await fs.readdir(server.writePath("mods"))) {
let match = splitter.exec(entry);
if (match && match[1] !== "export") {
+3 -3
View File
@@ -188,7 +188,7 @@ function reorderDependencies(modules) {
if (cycle.includes(module.name)) {
cycle.push(module.name);
cycle.splice(0, cycle.indexOf(module.name))
cycle.splice(0, cycle.indexOf(module.name));
throw new Error(`Module dependency loop detected: ${cycle.join(" -> ")}`);
}
@@ -251,7 +251,7 @@ async function patch(savePath, modules) {
let moduleInfo = {
"name": module.name,
"files": [],
}
};
let dirs = [[module.path, ""]];
while (dirs.length) {
@@ -294,4 +294,4 @@ module.exports = {
_findRoot: findRoot,
_generateLoader: generateLoader,
_reorderDependencies: reorderDependencies,
}
};
+13 -13
View File
@@ -140,7 +140,7 @@ function randomDynamicPort() {
const start = 49152;
const end = 65535 + 1;
return Math.floor(Math.random() * (end - start) + start)
return Math.floor(Math.random() * (end - start) + start);
}
/**
@@ -206,7 +206,7 @@ class LineSplitter {
*/
constructor(callback) {
this._callback = callback;
this._partial = null
this._partial = null;
}
/**
@@ -278,12 +278,12 @@ function parseOutput(line, source) {
let output = {
source,
received: Date.now(),
}
};
// There are three broad categories of output from Factorio, the first kind
// starts with the seconds since the server started and has a format of
// " 0.704 message"
const secRegex = /^ {0,3}(\d+\.\d+) (.*)$/
const secRegex = /^ {0,3}(\d+\.\d+) (.*)$/;
let secMatch = secRegex.exec(line);
if (secMatch) {
output.format = "seconds";
@@ -293,7 +293,7 @@ function parseOutput(line, source) {
// A seconds output has two different kinds of formats: The first is a
// log level and source location and has a format of
// "Level File.cpp:123: message"
const secLogRegex = /^(\w+) (\w+\.cpp:\d+): (.*)$/
const secLogRegex = /^(\w+) (\w+\.cpp:\d+): (.*)$/;
let secLogMatch = secLogRegex.exec(secContent);
if (secLogMatch) {
output.type = "log";
@@ -310,7 +310,7 @@ function parseOutput(line, source) {
// The second category of output starts with a date stamp of the format
// "yyyy-mm-dd hh:mm:ss message"
} else {
const dateRegex = /^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d) (.*)$/
const dateRegex = /^(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d) (.*)$/;
let dateMatch = dateRegex.exec(line);
if (dateMatch) {
output.format = "date";
@@ -319,7 +319,7 @@ function parseOutput(line, source) {
// A date output has two general formats. The first is an action
// followed by a message and has a format of "[ACTION] message"
const dateActionRegex = /^\[(\w+)\] (.*)$/
const dateActionRegex = /^\[(\w+)\] (.*)$/;
let dateActionMatch = dateActionRegex.exec(dateContent);
if (dateActionMatch) {
output.type = "action";
@@ -523,14 +523,14 @@ class FactorioServer extends events.EventEmitter {
this.on("_autosave", function(name) {
this.emit("autosave-start", name);
this._runningAutosave = name;
})
});
this.on("_saved", function() {
if (this._runningAutosave) {
this.emit("autosave-finished", this._runningAutosave);
this._runningAutosave = null;
}
})
});
}
_check(expectedStates) {
@@ -566,7 +566,7 @@ class FactorioServer extends events.EventEmitter {
// Prevent malicious names
if (/[\\/\0]/.test(fileName)) {
throw new Error(`Invalid IPC file name '${fileName}'`)
throw new Error(`Invalid IPC file name '${fileName}'`);
}
if (fileName.endsWith(".json")) {
@@ -575,7 +575,7 @@ class FactorioServer extends events.EventEmitter {
} else {
let format = fileName.slice(fileName.lastIndexOf(".") + 1);
throw new Error(`Unknown IPC file format '${format}'`)
throw new Error(`Unknown IPC file format '${format}'`);
}
} else {
@@ -703,7 +703,7 @@ class FactorioServer extends events.EventEmitter {
} else {
let msg;
if (code !== null) {
msg = `Factorio server unexpectedly shut down with code ${code}`
msg = `Factorio server unexpectedly shut down with code ${code}`;
} else {
msg = `Factorio server was unexpectedly shut by down by signal ${signal}`;
}
@@ -865,7 +865,7 @@ class FactorioServer extends events.EventEmitter {
* @returns {string} response from server.
*/
async sendRcon(message, expectEmpty) {
this._check(["running", "stopping"])
this._check(["running", "stopping"]);
if (!this._rconReady) {
await events.once(this, "rcon-ready");
}
+1 -1
View File
@@ -33,4 +33,4 @@ async function getNewestFile(directory, filter = (name) => true) {
module.exports = {
getNewestFile,
}
};
+1 -1
View File
@@ -41,4 +41,4 @@ module.exports = async function({
await fs.outputFile(sslCertPath, forge.pki.certificateToPem(cert));
log("Generated certificate in: "+(Number(hrtime()-startNs) / 1e6)+" ms");
}
};
+3 -3
View File
@@ -14,8 +14,8 @@ const fs = require("fs");
*/
function hashStream(stream) {
return new Promise(function(resolve, reject) {
let hasher = crypto.createHash("sha1")
hasher.setEncoding("hex")
let hasher = crypto.createHash("sha1");
hasher.setEncoding("hex");
hasher.on("finish", function() {
resolve(hasher.read());
});
@@ -42,4 +42,4 @@ function hashFile(path) {
module.exports = {
hashStream,
hashFile,
}
};
+1 -1
View File
@@ -20,4 +20,4 @@ function basicType(value) {
module.exports = {
basicType,
}
};
+2 -2
View File
@@ -226,7 +226,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
url.pathname += "api/socket";
// Open WebSocket to master
console.log(`SOCKET | connecting to ${url}`)
console.log(`SOCKET | connecting to ${url}`);
this._socket = new WebSocket(url, {
// For now we do not verify TLS certificates since the default setup is
@@ -261,7 +261,7 @@ class WebSocketClientConnector extends WebSocketBaseConnector {
}
let delay = Math.random() * this._reconnectDelay;
console.log(`SOCKET | waiting ${delay.toLocaleString("en", { maximumFractionDigits: 2 })} seconds for reconnect`)
console.log(`SOCKET | waiting ${delay.toLocaleString("en", { maximumFractionDigits: 2 })} seconds for reconnect`);
this._reconnectId = setTimeout(() => {
this._reconnectId = null;
this._doConnect();
+2 -2
View File
@@ -35,7 +35,7 @@ class Link {
this.processMessage(payload);
} catch (err) {
if (err instanceof errors.InvalidMessage) {
console.error(`Invalid message on ${this.source}-${this.target} link: ${err.message}`)
console.error(`Invalid message on ${this.source}-${this.target} link: ${err.message}`);
if (err.errors) {
console.error(err.errors);
}
@@ -243,4 +243,4 @@ class Link {
module.exports = {
Link,
}
};
+4 -4
View File
@@ -226,7 +226,7 @@ class Request extends Message {
}
let messages = {}
let messages = {};
// Connection requests
let wsLinks = ["master-control", "control-master", "master-slave", "slave-master"];
@@ -396,7 +396,7 @@ messages.assignInstance = new Request({
"serialized_config": { type: "object" },
},
forwardTo: "instance",
})
});
messages.startInstance = new Request({
type: "start_instance",
@@ -705,7 +705,7 @@ class Event extends Message {
handler = async (message, event) => {
await link.broadcastEventToInstance(message, event);
await originalHandler.call(link, message, event);
}
};
}
}
@@ -860,4 +860,4 @@ module.exports = {
attachAllMessages,
messages,
}
};
+1 -1
View File
@@ -19,4 +19,4 @@ function escapeString(content) {
module.exports = {
escapeString,
}
};
+9 -9
View File
@@ -63,14 +63,14 @@ async function listMods(config, instance) {
date:mod.date,
factorio_ver:mod.factorio_version,
author:mod.author,
}
};
})));
});
// Had issues earlier due to bug in node-factorio-api, see https://github.com/Danacus/node-factorio-api/issues/2
// bug is resolved, thanks to @Danacus and @brotherpot
factorioAPI.getModsFromSaves().then(list => {
console.log("* Mods used in save:");
console.log(asTable(list[0].mods))
console.log(asTable(list[0].mods));
});
}).catch(reason => {
console.log("Failed to authenticate to factorio.com! Please check your connection and the username+token used for authentication in config.json");
@@ -84,8 +84,8 @@ async function listMods(config, instance) {
token: config.token,
require_ownership: false
}).then(() => {
console.log("\r\n")
console.log("* Mods shared by all instances:")
console.log("\r\n");
console.log("* Mods shared by all instances:");
factorioAPI.getInstalledMods().then(mods => {
console.log(asTable(mods));
resolve();
@@ -128,7 +128,7 @@ async function findMods(config, searchTerm) {
latest_version: mod.latest_release.version,
owner:mod.owner,
//license: mod.license_name,
}
};
}));
resolve(result);
// console.log(result);
@@ -202,7 +202,7 @@ async function addMod(config, term, instance) {
require_ownership: false
}).then(() => {
factorioAPI.searchMods(term).then(body => {
console.log(body)
console.log(body);
console.log("Im gonna download: "+body[0].name + " in version: " + body[0].latest_release.version);
factorioAPI.downloadMod( {name: body[0].name, version: body[0].latest_release.version}).then(()=>{
console.log("Mod downloaded");
@@ -242,7 +242,7 @@ async function removeMod(config, term, instance, force = false) {
fs.unlinkSync(path.join(modDirectory, modsMatchingFilter[i]));
console.log("Deleted "+modsMatchingFilter[i]);
}
} else console.log("Did not delete mods.")
} else console.log("Did not delete mods.");
}
resolve();
} else {
@@ -264,7 +264,7 @@ function downloadFromGitURL(url) {
let res = syncRequest("GET", url, {"headers":{"User-Agent":"factorioClusterio"}});
let downloadUrl = JSON.parse(res.getBody())[0].assets[0].browser_download_url;
let name = JSON.parse(res.getBody())[0].assets[0].name;
console.log(JSON.parse(res.getBody()))
console.log(JSON.parse(res.getBody()));
if (downloadUrl) {
console.log(downloadUrl);
let file = fs.createWriteStream("sharedMods/"+name);
@@ -291,4 +291,4 @@ module.exports = {
addMod,
removeMod,
downloadFromGitURL,
}
};
+1 -1
View File
@@ -76,7 +76,7 @@ let downloadList = [
url: "https://fonts.googleapis.com/css?family=Roboto",
file: "static/external/css/Roboto.css",
},
]
];
// initiate folder creations and downloads
function processMkdirRecursive(callback){
+3 -3
View File
@@ -17,7 +17,7 @@ a == c; // false
*/
module.exports.deepclone = function(obj){
return JSON.parse(JSON.stringify(obj));
}
};
/**
Checks if a string is valid JSON using try/catch. If passed an object it will always return true.
@param {string} string to verify
@@ -31,7 +31,7 @@ objectOps.isJSON(JSON.stringify({"thingy":"that is an object"})); // true
*/
module.exports.isJSON = function(string){
let stringIsJson = false;
let x
let x;
try {
x = JSON.parse(string);
} catch (e){
@@ -41,4 +41,4 @@ module.exports.isJSON = function(string){
stringIsJson = true;
}
return stringIsJson;
}
};
+9 -9
View File
@@ -46,7 +46,7 @@ function escapeLabelValue(value) {
}
function labelsToKey(labels, metricLabels) {
let items = []
let items = [];
if (labels.length === 1 && typeof labels[0] === "object") {
labels = labels[0];
for (let name of metricLabels) {
@@ -170,7 +170,7 @@ class ValueCollector extends Collector {
return candidate.get(name) === value;
});
if (hasLabels) {
mapping.delete(key)
mapping.delete(key);
}
}
}
@@ -208,7 +208,7 @@ class CounterChild extends ValueCollectorChild {
throw new Error("Expected value to be a positive number");
}
this._values.set(this._key, this._values.get(this._key) + value)
this._values.set(this._key, this._values.get(this._key) + value);
}
}
@@ -224,19 +224,19 @@ class Counter extends ValueCollector {
class GaugeChild extends ValueCollectorChild {
inc(value = 1) {
this._values.set(this._key, this._values.get(this._key) + value)
this._values.set(this._key, this._values.get(this._key) + value);
}
dec(value = 1) {
this._values.set(this._key, this._values.get(this._key) - value)
this._values.set(this._key, this._values.get(this._key) - value);
}
set(value) {
this._values.set(this._key, value)
this._values.set(this._key, value);
}
setToCurrentTime() {
this._values.set(this._key, Date.now() / 1000)
this._values.set(this._key, Date.now() / 1000);
}
}
@@ -323,7 +323,7 @@ async function* expositionLines(resultsIterator) {
if (first) {
first = false;
} else {
yield "\n"
yield "\n";
}
yield `# HELP ${result.metric.name} ${escapeHelp(result.metric.help)}\n`;
@@ -395,7 +395,7 @@ function deserializeResult(serializedResult) {
serializedResult.metric.labels,
),
samples: new Map(serializedResult.samples),
}
};
}
let defaultCollectors = {};
+1 -1
View File
@@ -53,7 +53,7 @@ function definePermission({ name, title, description, grantByDefault=false }) {
}
if (permissions.has(name)) {
throw new Error(`Permission '${name}' is already defined`)
throw new Error(`Permission '${name}' is already defined`);
}
permissions.set(name, new Permission(name, title, description, grantByDefault));