mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +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
+35
-35
@@ -4,10 +4,10 @@ let testLines = new Map([
|
||||
[
|
||||
" 1.306 Info RemoteCommandProcessor.cpp:131: Starting RCON interface at port 4000",
|
||||
{
|
||||
format: 'seconds',
|
||||
time: '1.306',
|
||||
type: 'log',
|
||||
level: 'Info',
|
||||
format: "seconds",
|
||||
time: "1.306",
|
||||
type: "log",
|
||||
level: "Info",
|
||||
file: "RemoteCommandProcessor.cpp:131",
|
||||
message: "Starting RCON interface at port 4000",
|
||||
}
|
||||
@@ -15,10 +15,10 @@ let testLines = new Map([
|
||||
[
|
||||
" 0.622 Warning FileUtil.cpp:527: test not found; using test.zip",
|
||||
{
|
||||
format: 'seconds',
|
||||
time: '0.622',
|
||||
type: 'log',
|
||||
level: 'Warning',
|
||||
format: "seconds",
|
||||
time: "0.622",
|
||||
type: "log",
|
||||
level: "Warning",
|
||||
file: "FileUtil.cpp:527",
|
||||
message: "test not found; using test.zip",
|
||||
}
|
||||
@@ -26,10 +26,10 @@ let testLines = new Map([
|
||||
[
|
||||
" 0.554 Error Main.cpp:839: require_user_verification must be enabled for public games.",
|
||||
{
|
||||
format: 'seconds',
|
||||
time: '0.554',
|
||||
type: 'log',
|
||||
level: 'Error',
|
||||
format: "seconds",
|
||||
time: "0.554",
|
||||
type: "log",
|
||||
level: "Error",
|
||||
file: "Main.cpp:839",
|
||||
message: "require_user_verification must be enabled for public games.",
|
||||
}
|
||||
@@ -37,27 +37,27 @@ let testLines = new Map([
|
||||
[
|
||||
" 640.910 Quitting: remote-quit.",
|
||||
{
|
||||
format: 'seconds',
|
||||
time: '640.910',
|
||||
type: 'generic',
|
||||
format: "seconds",
|
||||
time: "640.910",
|
||||
type: "generic",
|
||||
message: "Quitting: remote-quit.",
|
||||
}
|
||||
],
|
||||
[
|
||||
"1641.421 Goodbye",
|
||||
{
|
||||
format: 'seconds',
|
||||
time: '1641.421',
|
||||
type: 'generic',
|
||||
format: "seconds",
|
||||
time: "1641.421",
|
||||
type: "generic",
|
||||
message: "Goodbye",
|
||||
}
|
||||
],
|
||||
[
|
||||
"2019-01-20 10:30:04 [JOIN] User joined the game",
|
||||
{
|
||||
format: 'date',
|
||||
time: '2019-01-20 10:30:04',
|
||||
type: 'action',
|
||||
format: "date",
|
||||
time: "2019-01-20 10:30:04",
|
||||
type: "action",
|
||||
action: "JOIN",
|
||||
message: "User joined the game",
|
||||
}
|
||||
@@ -65,9 +65,9 @@ let testLines = new Map([
|
||||
[
|
||||
"2019-01-20 10:30:07 [CHAT] User: chat message",
|
||||
{
|
||||
format: 'date',
|
||||
time: '2019-01-20 10:30:07',
|
||||
type: 'action',
|
||||
format: "date",
|
||||
time: "2019-01-20 10:30:07",
|
||||
type: "action",
|
||||
action: "CHAT",
|
||||
message: "User: chat message",
|
||||
}
|
||||
@@ -75,9 +75,9 @@ let testLines = new Map([
|
||||
[
|
||||
"2019-01-20 10:30:14 [COMMAND] User (command): blah",
|
||||
{
|
||||
format: 'date',
|
||||
time: '2019-01-20 10:30:14',
|
||||
type: 'action',
|
||||
format: "date",
|
||||
time: "2019-01-20 10:30:14",
|
||||
type: "action",
|
||||
action: "COMMAND",
|
||||
message: "User (command): blah",
|
||||
}
|
||||
@@ -85,18 +85,18 @@ let testLines = new Map([
|
||||
[
|
||||
"2019-01-20 10:30:14 Cannot execute command. Error: [string \"blah\"]:1: syntax error near <eof>",
|
||||
{
|
||||
format: 'date',
|
||||
time: '2019-01-20 10:30:14',
|
||||
type: 'generic',
|
||||
format: "date",
|
||||
time: "2019-01-20 10:30:14",
|
||||
type: "generic",
|
||||
message: "Cannot execute command. Error: [string \"blah\"]:1: syntax error near <eof>",
|
||||
}
|
||||
],
|
||||
[
|
||||
"2019-01-20 10:30:21 [LEAVE] User left the game",
|
||||
{
|
||||
format: 'date',
|
||||
time: '2019-01-20 10:30:21',
|
||||
type: 'action',
|
||||
format: "date",
|
||||
time: "2019-01-20 10:30:21",
|
||||
type: "action",
|
||||
action: "LEAVE",
|
||||
message: "User left the game",
|
||||
}
|
||||
@@ -104,8 +104,8 @@ let testLines = new Map([
|
||||
[
|
||||
"Error while running event level::on_nth_tick(1)",
|
||||
{
|
||||
format: 'none',
|
||||
type: 'generic',
|
||||
format: "none",
|
||||
type: "generic",
|
||||
message: "Error while running event level::on_nth_tick(1)",
|
||||
}
|
||||
],
|
||||
|
||||
+30
-30
@@ -50,20 +50,20 @@ describe("lib/factorio", function() {
|
||||
|
||||
describe("generateLoader()", function() {
|
||||
let reference = [
|
||||
'-- Auto generated scenario module loader created by Clusterio',
|
||||
'-- Modifications to this file will be lost when loaded in Clusterio',
|
||||
'clusterio_patch_number = 1',
|
||||
'',
|
||||
"-- Auto generated scenario module loader created by Clusterio",
|
||||
"-- Modifications to this file will be lost when loaded in Clusterio",
|
||||
"clusterio_patch_number = 1",
|
||||
"",
|
||||
'local event_handler = require("event_handler")',
|
||||
'',
|
||||
'-- Scenario modules',
|
||||
"",
|
||||
"-- Scenario modules",
|
||||
'event_handler.add_lib(require("foo"))',
|
||||
'',
|
||||
'-- Clusterio modules',
|
||||
"",
|
||||
"-- Clusterio modules",
|
||||
'event_handler.add_lib(require("modules/spam/bar"))',
|
||||
'require("modules/spam/spam")',
|
||||
'',
|
||||
].join('\n');
|
||||
"",
|
||||
].join("\n");
|
||||
let patchInfo = {
|
||||
"patch_number": 1,
|
||||
"scenario": { "modules": ["foo"] },
|
||||
@@ -85,15 +85,15 @@ describe("lib/factorio", function() {
|
||||
describe("reorderDependencies()", function() {
|
||||
it("should reorder to satisfy simple dependency", function() {
|
||||
let modules = [
|
||||
{ name: 'a', version: '1.0.0', dependencies: {'b': '*'} },
|
||||
{ name: 'b', version: '1.0.0', dependencies: {} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {"b": "*"} },
|
||||
{ name: "b", version: "1.0.0", dependencies: {} },
|
||||
];
|
||||
factorio._reorderDependencies(modules);
|
||||
assert(modules[0].name === 'b', "Dependency was not reorederd");
|
||||
assert(modules[0].name === "b", "Dependency was not reorederd");
|
||||
});
|
||||
it("should throw on invalid version", function() {
|
||||
let modules = [
|
||||
{ name: 'a', version: 'foo', dependencies: {} },
|
||||
{ name: "a", version: "foo", dependencies: {} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
@@ -102,7 +102,7 @@ describe("lib/factorio", function() {
|
||||
});
|
||||
it("should throw on invalid version range", function() {
|
||||
let modules = [
|
||||
{ name: 'a', version: '1.0.0', dependencies: {'b': 'invalid'} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {"b": "invalid"} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
@@ -111,16 +111,16 @@ describe("lib/factorio", function() {
|
||||
});
|
||||
it("should throw on missing dependency", function() {
|
||||
let modules = [
|
||||
{ name: 'a', version: '1.0.0', dependencies: {'b': '*'} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {"b": "*"} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
new Error("Missing dependency b for module a")
|
||||
);
|
||||
modules = [
|
||||
{ name: 'a', version: '1.0.0', dependencies: {'b': '*'} },
|
||||
{ name: 'b', version: '1.0.0', dependencies: {'c': '*'} },
|
||||
{ name: 'c', version: '1.0.0', dependencies: {'d': '*'} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {"b": "*"} },
|
||||
{ name: "b", version: "1.0.0", dependencies: {"c": "*"} },
|
||||
{ name: "c", version: "1.0.0", dependencies: {"d": "*"} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
@@ -129,8 +129,8 @@ describe("lib/factorio", function() {
|
||||
});
|
||||
it("should throw on outdated dependency", function() {
|
||||
let modules = [
|
||||
{ name: 'a', version: '1.0.0', dependencies: {} },
|
||||
{ name: 'b', version: '1.0.0', dependencies: {'a': '>=2'} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {} },
|
||||
{ name: "b", version: "1.0.0", dependencies: {"a": ">=2"} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
@@ -139,18 +139,18 @@ describe("lib/factorio", function() {
|
||||
});
|
||||
it("should throw on dependency loops", function() {
|
||||
let modules = [
|
||||
{ name: 'a', version: '1.0.0', dependencies: {'b': '*'} },
|
||||
{ name: 'b', version: '1.0.0', dependencies: {'a': '*'} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {"b": "*"} },
|
||||
{ name: "b", version: "1.0.0", dependencies: {"a": "*"} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
new Error("Module dependency loop detected: a -> b -> a")
|
||||
);
|
||||
modules = [
|
||||
{ name: 'd', version: '1.0.0', dependencies: {'b': '*'} },
|
||||
{ name: 'a', version: '1.0.0', dependencies: {'b': '*'} },
|
||||
{ name: 'b', version: '1.0.0', dependencies: {'c': '*'} },
|
||||
{ name: 'c', version: '1.0.0', dependencies: {'a': '*'} },
|
||||
{ name: "d", version: "1.0.0", dependencies: {"b": "*"} },
|
||||
{ name: "a", version: "1.0.0", dependencies: {"b": "*"} },
|
||||
{ name: "b", version: "1.0.0", dependencies: {"c": "*"} },
|
||||
{ name: "c", version: "1.0.0", dependencies: {"a": "*"} },
|
||||
];
|
||||
assert.throws(
|
||||
() => factorio._reorderDependencies(modules),
|
||||
@@ -170,7 +170,7 @@ describe("lib/factorio", function() {
|
||||
}
|
||||
}
|
||||
|
||||
let names = ['a', 'b', 'c'];
|
||||
let names = ["a", "b", "c"];
|
||||
let successCount = 0;
|
||||
const bitCount = names.length * (names.length - 1);
|
||||
for (let i=0; i < 2**bitCount; i++) {
|
||||
@@ -186,10 +186,10 @@ describe("lib/factorio", function() {
|
||||
let dependencies = {};
|
||||
for (let k=0; k < names.length - 1; k++) {
|
||||
if (bits[k + j * (names.length - 1)]) {
|
||||
dependencies[names[k + (k >= j)]] = '*';
|
||||
dependencies[names[k + (k >= j)]] = "*";
|
||||
}
|
||||
}
|
||||
modules.push({ name, version: '1.0.0', dependencies });
|
||||
modules.push({ name, version: "1.0.0", dependencies });
|
||||
}
|
||||
let success = false;
|
||||
try {
|
||||
|
||||
+11
-11
@@ -157,8 +157,8 @@ describe("lib/factorio/server", function() {
|
||||
describe("parseOutput()", function() {
|
||||
it("should parse the test lines", function() {
|
||||
for (let [line, reference] of testLines) {
|
||||
reference.source = 'test';
|
||||
let output = factorio._parseOutput(line, 'test');
|
||||
reference.source = "test";
|
||||
let output = factorio._parseOutput(line, "test");
|
||||
delete output.received;
|
||||
assert.deepEqual(output, reference);
|
||||
}
|
||||
@@ -187,46 +187,46 @@ describe("lib/factorio/server", function() {
|
||||
|
||||
describe("._handleIpc()", function() {
|
||||
it("should emit the correct ipc event", async function() {
|
||||
let waiter = events.once(server, 'ipc-channel');
|
||||
let waiter = events.once(server, "ipc-channel");
|
||||
await server._handleIpc(Buffer.from('\f$ipc:channel?j"value"'));
|
||||
let result = await waiter;
|
||||
assert.equal(result[0], "value");
|
||||
});
|
||||
it("should handle special characters in channel name", async function() {
|
||||
let waiter = events.once(server, 'ipc-$ ?\x00\x0a:');
|
||||
let waiter = events.once(server, "ipc-$ ?\x00\x0a:");
|
||||
await server._handleIpc(Buffer.from('\f$ipc:$ \\x3f\\x00\\x0a:?j"value"'));
|
||||
let result = await waiter;
|
||||
assert.equal(result[0], "value");
|
||||
});
|
||||
it("should throw on malformed ipc line", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from('\f$ipc:blah')),
|
||||
server._handleIpc(Buffer.from("\f$ipc:blah")),
|
||||
new Error('Malformed IPC line "\f$ipc:blah"')
|
||||
);
|
||||
})
|
||||
it("should throw on unknown type", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from('\f$ipc:channel??')),
|
||||
server._handleIpc(Buffer.from("\f$ipc:channel??")),
|
||||
new Error("Unknown IPC type '?'")
|
||||
);
|
||||
})
|
||||
it("should throw on unknown file type", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from('\f$ipc:channel?ffoo.invalid')),
|
||||
server._handleIpc(Buffer.from("\f$ipc:channel?ffoo.invalid")),
|
||||
new Error("Unknown IPC file format 'invalid'")
|
||||
);
|
||||
})
|
||||
it("should throw on file name with slash", async function() {
|
||||
await assert.rejects(
|
||||
server._handleIpc(Buffer.from('\f$ipc:channel?fa/b')),
|
||||
server._handleIpc(Buffer.from("\f$ipc:channel?fa/b")),
|
||||
new Error("Invalid IPC file name 'a/b'")
|
||||
);
|
||||
})
|
||||
it("should load and delete json file", async function() {
|
||||
let filePath = server.writePath('script-output', 'data.json');
|
||||
let filePath = server.writePath("script-output", "data.json");
|
||||
await fs.outputFile(filePath, '{"data":"spam"}');
|
||||
let waiter = events.once(server, 'ipc-channel');
|
||||
await server._handleIpc(Buffer.from('\f$ipc:channel?fdata.json'));
|
||||
let waiter = events.once(server, "ipc-channel");
|
||||
await server._handleIpc(Buffer.from("\f$ipc:channel?fdata.json"));
|
||||
let result = await waiter;
|
||||
assert.deepEqual(result[0], { "data": "spam" });
|
||||
assert(!await fs.pathExists(filePath), "File was not deleted");
|
||||
|
||||
Reference in new issue
Block a user