Ignore BOM in locale files

Ignore BOM at the start of Factorio locale files as this is a thing
Factorio also does.

Fixes #507
This commit is contained in:
Hornwitser committed 2023-11-24 20:53:16 +01:00
1 parent 6eda1f78d5
commit f23e442c4c
3 files changed
+14

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
[spam]
foo=bar
+7
View File
@@ -1,5 +1,6 @@
"use strict";
const assert = require("assert").strict;
const fs = require("fs-extra");
const lib = require("@clusterio/lib");
describe("lib/ini", function() {
@@ -58,6 +59,12 @@ describe("lib/ini", function() {
new Error("Duplicated key key on line 2")
);
});
it("should parse a file with BOM", async function() {
assert.deepEqual(
lib.parse(await fs.readFile("test/file/bom.cfg", "utf8")),
{ spam: { foo: "bar" }},
);
});
});
describe("stringify()", function() {
it("should serialize to reference output", function() {