factorio-test-cli 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/run.js +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "factorio-test-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "A CLI to run FactorioTest.",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/GlassBricks/FactorioTest",
package/run.js CHANGED
@@ -3,7 +3,7 @@ import * as os from "os";
3
3
  import * as fsp from "fs/promises";
4
4
  import * as fs from "fs";
5
5
  import * as path from "path";
6
- import { spawn } from "child_process";
6
+ import { spawn, spawnSync } from "child_process";
7
7
  import BufferLineSplitter from "./buffer-line-splitter.js";
8
8
  import chalk from "chalk";
9
9
  const thisCommand = program
@@ -235,12 +235,18 @@ function runProcess(inheritStdio, command, ...args) {
235
235
  });
236
236
  });
237
237
  }
238
+ function factorioIsInPath() {
239
+ const result = spawnSync("factorio", ["--version"], { stdio: "ignore" });
240
+ return result.status === 0;
241
+ }
238
242
  function autoDetectFactorioPath() {
243
+ if (factorioIsInPath()) {
244
+ return "factorio";
245
+ }
239
246
  let pathsToTry;
240
247
  // check if is linux
241
248
  if (os.platform() === "linux" || os.platform() === "darwin") {
242
249
  pathsToTry = [
243
- "factorio",
244
250
  "~/.local/share/Steam/steamapps/common/Factorio/bin/x64/factorio",
245
251
  "~/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/Contents/MacOS/factorio",
246
252
  "~/.factorio/bin/x64/factorio",