diff --git a/client.js b/client.js index a723b15f..2fa2f555 100644 --- a/client.js +++ b/client.js @@ -75,7 +75,7 @@ class Instance { // save instance config await fs.outputFile(instance.path("config.json"), JSON.stringify(instanceConfig, null, 4)); - let serverSettings = await instance.server.exampleSettings(); + let serverSettings = await factorio.FactorioServer.exampleSettings(path.join(factorioDir, "data")); let gameName = "Clusterio instance: " + instance.name; if (options.username) { gameName = options.username + "'s clusterio " + instance.name; diff --git a/lib/factorio/server.js b/lib/factorio/server.js index 0f45921a..831f1173 100644 --- a/lib/factorio/server.js +++ b/lib/factorio/server.js @@ -753,10 +753,11 @@ class FactorioServer extends events.EventEmitter { * * Loads server-settings.example.json from the data dir. * + * @param {string} dataDir - The data directory for Factorio * @returns {object} the parsed server-settings. */ - async exampleSettings() { - return JSON.parse(await fs.readFile(this.dataPath("server-settings.example.json"), "utf-8")); + static async exampleSettings(dataDir) { + return JSON.parse(await fs.readFile(path.join(dataDir, "server-settings.example.json"), "utf-8")); } async _writeConfigIni() { diff --git a/test/integration/server.js b/test/integration/server.js index 0c135ec8..327ed2d0 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -45,7 +45,7 @@ describe("Integration of lib/factorio/server", function() { describe(".exampleSettings()", function() { let settings; it("returns an object", async function() { - settings = await server.exampleSettings(); + settings = await factorio.FactorioServer.exampleSettings(path.join("factorio", "data")); assert(typeof settings === "object"); });