mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 23:14:53 +09:00
factorioServer: Tried adding function for map creation, failed.
This commit is contained in:
1 parent
e55bf71431
commit
9a0ce97746
2 files changed
+24
-3
No files matched your search
+6
-2
@@ -125,12 +125,16 @@ module.exports = class factorioServer {
|
||||
await createInstance();
|
||||
}
|
||||
this.onProgress("log", "Starting map creation");
|
||||
child_process.spawnSync(
|
||||
'./'+this.factorioDirectory + '/bin/x64/factorio', [
|
||||
let code = child_process.spawnSync(
|
||||
this.factorioDirectory + '/bin/x64/factorio', [
|
||||
'-c', this.instanceDirectory + '/config.ini',
|
||||
'--create', this.instanceDirectory + '/saves/'+name,
|
||||
'--server-settings', this.instanceDirectory + '/server-settings.json',
|
||||
]
|
||||
);
|
||||
console.log(code.stdout.toString("utf8"))
|
||||
console.log(code)
|
||||
this.onProgress("log", "Map created");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+18
-1
@@ -39,7 +39,7 @@ describe("factorioServer/index.js", ()=>{
|
||||
});
|
||||
});
|
||||
describe(".initialize()", ()=>{
|
||||
it("server.initialize creates an instance", done => {
|
||||
it("creates an instance", done => {
|
||||
let server = new factorioServer({
|
||||
instanceDirectory: path.resolve(__dirname, "_testData_initialize"),
|
||||
instanceName: "Unit testing instance",
|
||||
@@ -51,4 +51,21 @@ describe("factorioServer/index.js", ()=>{
|
||||
}).catch(e => console.log(e));
|
||||
});
|
||||
});
|
||||
describe(".createMap()", ()=>{
|
||||
it("creates a map file as instanceDirectory/saves/map.zip", async ()=>{
|
||||
let server = new factorioServer({
|
||||
instanceDirectory: path.resolve(__dirname, "_testData_createMap"),
|
||||
instanceName: "Unit testing instance",
|
||||
});
|
||||
await server.initialize();
|
||||
let maps = fs.readdirSync(path.resolve(__dirname, "_testData_createMap", "saves"));
|
||||
assert.equal(maps.length, 0);
|
||||
await server.createMap();
|
||||
let maps2 = fs.readdirSync(path.resolve(__dirname, "_testData_createMap", "saves"));
|
||||
assert(maps2.includes("map.zip"));
|
||||
|
||||
server.deleteInstance();
|
||||
return true;
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user