mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
Use double quotes
Convert existing mix of double quotes and single quotes to only use double quotes unless the string contains double quotes.
This commit is contained in:
1 parent
efd759bec5
commit
34aaeee354
48 files changed
+708
-712
No files matched your search
@@ -10,10 +10,10 @@ module.exports = {
|
||||
|
||||
messages: {
|
||||
chat: new link.Event({
|
||||
type: 'global_chat:chat',
|
||||
links: ['instance-slave', 'slave-master', 'master-slave', 'slave-instance'],
|
||||
forwardTo: 'master',
|
||||
broadcastTo: 'instance',
|
||||
type: "global_chat:chat",
|
||||
links: ["instance-slave", "slave-master", "master-slave", "slave-instance"],
|
||||
forwardTo: "master",
|
||||
broadcastTo: "instance",
|
||||
eventProperties: {
|
||||
"instance_name": { type: "string" },
|
||||
"content": { type: "string" },
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const assert = require('assert').strict;
|
||||
const assert = require("assert").strict;
|
||||
|
||||
const mock = require('../../../test/mock');
|
||||
const lines = require('../../../test/lib/factorio/lines');
|
||||
const instance = require('../instance');
|
||||
const info = require('../info');
|
||||
const mock = require("../../../test/mock");
|
||||
const lines = require("../../../test/lib/factorio/lines");
|
||||
const instance = require("../instance");
|
||||
const info = require("../info");
|
||||
|
||||
|
||||
describe("global_chat plugin", function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// These are libraries that does not have any units test, they are
|
||||
// required here in order to track coverage for them.
|
||||
|
||||
require('../instance');
|
||||
require('../master');
|
||||
require("../instance");
|
||||
require("../master");
|
||||
@@ -1,28 +1,28 @@
|
||||
const plugin = require('lib/plugin');
|
||||
const { Gauge } = require('lib/prometheus');
|
||||
const plugin = require("lib/plugin");
|
||||
const { Gauge } = require("lib/prometheus");
|
||||
|
||||
|
||||
const instancePlayerCount = new Gauge(
|
||||
"clusterio_statistics_exporter_instance_player_count", "Amount of players connected to this cluster",
|
||||
{ labels: ['instance_id'] }
|
||||
{ labels: ["instance_id"] }
|
||||
);
|
||||
const instanceGameTicksTotal = new Gauge(
|
||||
"clusterio_statistics_exporter_instance_game_ticks_total", "Game tick an instance has progressed to",
|
||||
{ labels: ['instance_id'] }
|
||||
{ labels: ["instance_id"] }
|
||||
);
|
||||
const instanceForceFlowStatistics = new Gauge(
|
||||
"clusterio_statistics_exporter_instance_force_flow_statistics", "Items/fluids/enemies/buildings produced/built/killed by a force",
|
||||
{ labels: ['instance_id', 'force', 'statistic', 'direction', 'name'] },
|
||||
{ labels: ["instance_id", "force", "statistic", "direction", "name"] },
|
||||
);
|
||||
const instanceGameFlowStatistics = new Gauge(
|
||||
"clusterio_statistics_exporter_instance_game_flow_statistics", "Pollution produced/consumed in the game",
|
||||
{ labels: ['instance_id', 'statistic', 'direction', 'name'] },
|
||||
{ labels: ["instance_id", "statistic", "direction", "name"] },
|
||||
);
|
||||
|
||||
|
||||
class InstancePlugin extends plugin.BaseInstancePlugin {
|
||||
async onMetrics() {
|
||||
let string = await this.instance.server.sendRcon('/sc statistics_exporter.export()');
|
||||
let string = await this.instance.server.sendRcon("/sc statistics_exporter.export()");
|
||||
let stats;
|
||||
try {
|
||||
stats = JSON.parse(string);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const assert = require('assert').strict;
|
||||
const assert = require("assert").strict;
|
||||
|
||||
const mock = require('../../../test/mock');
|
||||
const instance = require('../instance');
|
||||
const info = require('../info');
|
||||
const mock = require("../../../test/mock");
|
||||
const instance = require("../instance");
|
||||
const info = require("../info");
|
||||
|
||||
|
||||
describe("statistics_exporter plugin", function() {
|
||||
@@ -16,7 +16,7 @@ describe("statistics_exporter plugin", function() {
|
||||
describe(".onMetrics()", function() {
|
||||
it("should record statistics", async function() {
|
||||
instancePlugin.instance.server.rconCommandResults.set(
|
||||
'/sc statistics_exporter.export()',
|
||||
"/sc statistics_exporter.export()",
|
||||
JSON.stringify({
|
||||
game_tick: 100,
|
||||
player_count: 3,
|
||||
@@ -39,19 +39,19 @@ describe("statistics_exporter plugin", function() {
|
||||
|
||||
await instancePlugin.onMetrics();
|
||||
|
||||
assert.equal(instance._instancePlayerCount.labels('7357').get(), 3);
|
||||
assert.equal(instance._instanceGameTicksTotal.labels('7357').get(), 100);
|
||||
assert.equal(instance._instancePlayerCount.labels("7357").get(), 3);
|
||||
assert.equal(instance._instanceGameTicksTotal.labels("7357").get(), 100);
|
||||
assert.equal(instance._instanceForceFlowStatistics.labels(
|
||||
'7357', 'player', 'item_production_statistics', 'input', 'inserter').get(),
|
||||
"7357", "player", "item_production_statistics", "input", "inserter").get(),
|
||||
10);
|
||||
assert.equal(instance._instanceGameFlowStatistics.labels(
|
||||
'7357', 'pollution_statistics', 'input', 'boiler').get(),
|
||||
"7357", "pollution_statistics", "input", "boiler").get(),
|
||||
2000);
|
||||
});
|
||||
it("should pass on JSON parse errors", async function() {
|
||||
let string = 'An error occured\n';
|
||||
let string = "An error occured\n";
|
||||
instancePlugin.instance.server.rconCommandResults.set(
|
||||
'/sc statistics_exporter.export()', string
|
||||
"/sc statistics_exporter.export()", string
|
||||
);
|
||||
|
||||
let errorMessage;
|
||||
|
||||
@@ -104,7 +104,7 @@ function doleDivider({
|
||||
object.count /= ((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation;
|
||||
object.count = Math.round(object.count);
|
||||
if (logItemTransfers) {
|
||||
console.info(`Serving ${object.count}/${originalCount} ${object.name} from ${itemCount} ${object.name} with dole division factor ${(_doleDivisionFactor[object.name]||0)} (real=${((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation}), item is ${itemCount > object.count?'stocked':'short'}.`);
|
||||
console.info(`Serving ${object.count}/${originalCount} ${object.name} from ${itemCount} ${object.name} with dole division factor ${(_doleDivisionFactor[object.name]||0)} (real=${((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation}), item is ${itemCount > object.count?"stocked":"short"}.`);
|
||||
}
|
||||
|
||||
// Update existing items if item name already exists
|
||||
|
||||
@@ -7,8 +7,8 @@ function drawcontents(data) {
|
||||
// allow searching for multiple criteria separated by space
|
||||
var searchArgs = document.querySelector("#search").value;
|
||||
searchArgs = searchArgs.trim();
|
||||
searchArgs = '(' + searchArgs.replace(/ +/g,")|(") + ')';
|
||||
const search = new RegExp(searchArgs, 'i');
|
||||
searchArgs = "(" + searchArgs.replace(/ +/g,")|(") + ")";
|
||||
const search = new RegExp(searchArgs, "i");
|
||||
data = data.filter(function(item) {
|
||||
return search.test(item.name);
|
||||
})
|
||||
@@ -25,7 +25,7 @@ function drawcontents(data) {
|
||||
|
||||
let row = rows[i];
|
||||
if(!row) {
|
||||
row = document.createElement('tr');
|
||||
row = document.createElement("tr");
|
||||
row.innerHTML = "<td><div></div></td><td class=name></td><td class=count></td>";
|
||||
table.appendChild(row);
|
||||
}
|
||||
@@ -51,13 +51,13 @@ function drawcontents(data) {
|
||||
}
|
||||
}
|
||||
|
||||
const name = row.querySelector('.name');
|
||||
const name = row.querySelector(".name");
|
||||
if(name.textContent !== localeName) {
|
||||
name.textContent = localeName;
|
||||
}
|
||||
|
||||
const count = row.querySelector('.count');
|
||||
if(count.textContent !== ''+item.count) {
|
||||
const count = row.querySelector(".count");
|
||||
if(count.textContent !== ""+item.count) {
|
||||
count.textContent = item.count;
|
||||
}
|
||||
});
|
||||
@@ -93,6 +93,6 @@ function sortByKey(array, key) {
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelector("#search").addEventListener('input', function() {
|
||||
document.querySelector("#search").addEventListener("input", function() {
|
||||
drawcontents();
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
// These are libraries that does not have any units test, they are
|
||||
// required here in order to track coverage for them.
|
||||
|
||||
require('../instance');
|
||||
require('../master');
|
||||
require('../dole');
|
||||
require('../dole_nn_base');
|
||||
require("../instance");
|
||||
require("../master");
|
||||
require("../dole");
|
||||
require("../dole_nn_base");
|
||||
Reference in new issue
Block a user