Merge pull request #363 from drouarb/master

MacOS compatibility
This commit is contained in:
Arvids Godjuks authored and GitHub committed 2021-03-23 20:59:44 +02:00
commit f46f40ad4a
2 files changed
+41 -3

No files matched your search

+24
View File
@@ -34,6 +34,7 @@ Go to the page for the [1.2.x branch][1.2.x] for instructions on how to install
* [Plugins](#plugins) * [Plugins](#plugins)
* [Ubuntu setup](#ubuntu-setup) * [Ubuntu setup](#ubuntu-setup)
* [Windows setup](#windows-setup) * [Windows setup](#windows-setup)
* [MacOS setup](#macos-setup)
* [Installing Plugins](#installing-plugins) * [Installing Plugins](#installing-plugins)
* [Configure Master Server](#configure-master-server) * [Configure Master Server](#configure-master-server)
* [Hosting Behind Proxy](#hosting-behind-proxy) * [Hosting Behind Proxy](#hosting-behind-proxy)
@@ -164,6 +165,29 @@ Clusterio runs on Node.js v12 and up, and v10.16.0+.
3. Go to the parent folder of the folder that Steam opened and copy the Factorio folder into the factorio folder created in step 1. 3. Go to the parent folder of the folder that Steam opened and copy the Factorio folder into the factorio folder created in step 1.
## MacOS Setup
**Requirements**
download and install nodeJS 12 from http://nodejs.org or brew (`brew install node`). Clusterio runs on Node.js v12 and
up, and v10.16.0+.
1. Open Terminal or Command prompt in the directory you want to install to and run the following commands.
```bash
mkdir clusterio
cd clusterio
npm init -y
npm install @clusterio/master @clusterio/slave @clusterio/ctl
```
2. Obtain Factorio:
Install Factorio and copy the factorio.app/Contents in your clusterio install folder as factorio.
If you installed factorio on your mac you can run
```bash
cp -r /Applications/factorio.app/Contents/ factorio
```
## Installing Plugins ## Installing Plugins
+17 -3
View File
@@ -832,7 +832,7 @@ class FactorioServer extends events.EventEmitter {
await this._writeConfigIni(); await this._writeConfigIni();
this._server = child_process.spawn( this._server = child_process.spawn(
this.dataPath("..", "bin", "x64", "factorio"), this.binaryPath(),
[ [
"--config", this.writePath("config.ini"), "--config", this.writePath("config.ini"),
"--create", this.writePath("saves", name), "--create", this.writePath("saves", name),
@@ -871,7 +871,7 @@ class FactorioServer extends events.EventEmitter {
await this._writeConfigIni(); await this._writeConfigIni();
this._server = child_process.spawn( this._server = child_process.spawn(
this.dataPath("..", "bin", "x64", "factorio"), this.binaryPath(),
[ [
"--config", this.writePath("config.ini"), "--config", this.writePath("config.ini"),
"--start-server", this.writePath("saves", save), "--start-server", this.writePath("saves", save),
@@ -906,7 +906,7 @@ class FactorioServer extends events.EventEmitter {
await this._writeConfigIni(); await this._writeConfigIni();
this._server = child_process.spawn( this._server = child_process.spawn(
this.dataPath("..", "bin", "x64", "factorio"), this.binaryPath(),
[ [
"--config", this.writePath("config.ini"), "--config", this.writePath("config.ini"),
"--start-server-load-scenario", scenario, "--start-server-load-scenario", scenario,
@@ -1102,6 +1102,20 @@ class FactorioServer extends events.EventEmitter {
return path.join(this._dataDir, ...parts); return path.join(this._dataDir, ...parts);
} }
/**
* Get Factorio binary path
*
* Get the path to the factorio binary depending on the platform (MacOS support)
*
* @returns {string} Path to factorio binary
*/
binaryPath() {
if (process.platform === "darwin") {
return this.dataPath("..", "MacOS", "factorio");
}
return this.dataPath("..", "bin", "x64", "factorio");
}
/** /**
* Return path in write directory * Return path in write directory
* *