Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get game file based on install location #12

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "screeps-steamless-client",
"type": "module",
"version": "1.2.0",
"version": "1.2.1",
"bin": "dist/index.js",
"scripts": {
"eslint": "eslint $(git ls-files '*.ts' '*.tsx')",
Expand Down Expand Up @@ -36,6 +36,7 @@
"jszip": "3.7.1",
"koa": "2.13.1",
"koa-conditional-get": "3.0.0",
"node-fetch": "2.6.1"
"node-fetch": "2.6.1",
"steam-game-path": "^2.2.0"
}
}
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import koaConditionalGet from 'koa-conditional-get';
import jsBeautify from 'js-beautify';
import JSZip from 'jszip';
import fetch from 'node-fetch';
import { getGamePath } from "steam-game-path";

// Parse program arguments
const argv = function() {
Expand Down Expand Up @@ -52,12 +53,10 @@ proxy.on('error', err => console.error(err));
// Locate and read `package.nw`
const [ data, stat ] = await async function() {
const path = argv.package ?? function() {
switch (process.platform) {
case 'darwin': return new URL('./Library/Application Support/Steam/steamapps/common/Screeps/package.nw', `${pathToFileURL(os.homedir())}/`);
case 'win32': return 'C:\\Program Files (x86)\\Steam\\steamapps\\common\\Screeps\\package.nw';
default: return undefined;
}
}();
const steam = getGamePath(464350);
if (!steam || !steam.game) return undefined;
return steam.game.path + "\\package.nw";
Copy link
Contributor

@Jomik Jomik Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong. Mac (and Linux) uses forward slash. Let's just check process.platform or path.join?

}();
if (!path) {
console.log('Could not find `package.nw`. Please check `--package` argument');
process.exit(1);
Expand Down