mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13: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
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user