mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
still trying to fix paths
This commit is contained in:
1 parent
9a0ce97746
commit
dfa5d9ad16
3 files changed
+20
-8
No files matched your search
+10
-5
@@ -12,8 +12,10 @@ This class has the responsiblity of :
|
|||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const child_process = require("child_process");
|
const child_process = require("child_process");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
const mkdirp = require("mkdirp");
|
const mkdirp = require("mkdirp");
|
||||||
|
const appRootPath = require("app-root-path");
|
||||||
|
|
||||||
const fileOps = require("_app/fileOps");
|
const fileOps = require("_app/fileOps");
|
||||||
|
|
||||||
@@ -125,12 +127,15 @@ module.exports = class factorioServer {
|
|||||||
await createInstance();
|
await createInstance();
|
||||||
}
|
}
|
||||||
this.onProgress("log", "Starting map creation");
|
this.onProgress("log", "Starting map creation");
|
||||||
|
console.log(this.factorioDirectory + '/bin/x64/factorio')
|
||||||
let code = child_process.spawnSync(
|
let code = child_process.spawnSync(
|
||||||
this.factorioDirectory + '/bin/x64/factorio', [
|
path.resolve(this.factorioDirectory, 'bin', 'x64', 'factorio'), [
|
||||||
'-c', this.instanceDirectory + '/config.ini',
|
'-c', path.resolve(this.instanceDirectory,'config.ini'),
|
||||||
'--create', this.instanceDirectory + '/saves/'+name,
|
'--create', path.resolve(this.instanceDirectory, 'saves',name),
|
||||||
'--server-settings', this.instanceDirectory + '/server-settings.json',
|
'--server-settings', path.resolve(this.instanceDirectory, 'server-settings.json'),
|
||||||
]
|
],{
|
||||||
|
cwd:process.cwd(),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
console.log(code.stdout.toString("utf8"))
|
console.log(code.stdout.toString("utf8"))
|
||||||
console.log(code)
|
console.log(code)
|
||||||
|
|||||||
+9
-3
@@ -2,6 +2,8 @@ const assert = require("assert");
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
|
const appRootPath = require("app-root-path");
|
||||||
|
|
||||||
const factorioServer = require("./index.js");
|
const factorioServer = require("./index.js");
|
||||||
|
|
||||||
describe("factorioServer/index.js", ()=>{
|
describe("factorioServer/index.js", ()=>{
|
||||||
@@ -53,15 +55,19 @@ describe("factorioServer/index.js", ()=>{
|
|||||||
});
|
});
|
||||||
describe(".createMap()", ()=>{
|
describe(".createMap()", ()=>{
|
||||||
it("creates a map file as instanceDirectory/saves/map.zip", async ()=>{
|
it("creates a map file as instanceDirectory/saves/map.zip", async ()=>{
|
||||||
|
let relativePath = __dirname.replace(appRootPath, "").substr(1);
|
||||||
let server = new factorioServer({
|
let server = new factorioServer({
|
||||||
instanceDirectory: path.resolve(__dirname, "_testData_createMap"),
|
instanceDirectory: path.resolve(appRootPath+"", relativePath, "_testData_createMap"),
|
||||||
instanceName: "Unit testing instance",
|
instanceName: "Unit testing instance",
|
||||||
});
|
});
|
||||||
await server.initialize();
|
await server.initialize();
|
||||||
let maps = fs.readdirSync(path.resolve(__dirname, "_testData_createMap", "saves"));
|
console.log(appRootPath+"")
|
||||||
|
console.log(relativePath)
|
||||||
|
console.log(path.resolve(appRootPath+"", relativePath, "_testData_createMap", "saves"))
|
||||||
|
let maps = fs.readdirSync(path.resolve(appRootPath+"", relativePath, "_testData_createMap", "saves"));
|
||||||
assert.equal(maps.length, 0);
|
assert.equal(maps.length, 0);
|
||||||
await server.createMap();
|
await server.createMap();
|
||||||
let maps2 = fs.readdirSync(path.resolve(__dirname, "_testData_createMap", "saves"));
|
let maps2 = fs.readdirSync(path.resolve(appRootPath+"", relativePath, "_testData_createMap", "saves"));
|
||||||
assert(maps2.includes("map.zip"));
|
assert(maps2.includes("map.zip"));
|
||||||
|
|
||||||
server.deleteInstance();
|
server.deleteInstance();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
"author": "Danielv123",
|
"author": "Danielv123",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"app-root-path": "^2.0.1",
|
||||||
"as-table": "^1.0.31",
|
"as-table": "^1.0.31",
|
||||||
"averaged-timeseries": "^1.4.0",
|
"averaged-timeseries": "^1.4.0",
|
||||||
"body-parser": "^1.18.2",
|
"body-parser": "^1.18.2",
|
||||||
|
|||||||
Reference in new issue
Block a user