-
-
Notifications
You must be signed in to change notification settings - Fork 101
Improved Linux detection fixes #143
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
Open
XenHat
wants to merge
23
commits into
OpenAsar:main
Choose a base branch
from
XenHat:improved-detection-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1a31901
process: improve linux game detection
Justsnoopy30 d49e76a
process: small fix for false positives
Justsnoopy30 a8bf750
process: further improve game detection for Linux
XenHat e99dccd
process: add missing line break in performance logging
XenHat ea53247
process: update discord game db
XenHat 357300d
process: tweak a debug logging line
XenHat 217e9c7
process: fix game detection for many games
XenHat 1753e97
process: work around false positive for Dolphin Emulator on Linux
XenHat 96b48e3
process: stricter check for dolphin false positive
XenHat c3d4e46
Accept workaround for Java
XenHat aab4bb7
merge with local version used for testing
XenHat 669145e
add more matching debug printing for now
XenHat 48add08
update detectable.json
XenHat 7a0eafa
add more debugging
XenHat 28827cb
Comment out debugging in preparation for an eventual upstreaming
XenHat 09c787e
code style cleanup
XenHat 51e7911
process: add debug logging
XenHat 07ddca6
process: comment out debug logging until default log level is changed
XenHat c906099
apply OBS Streamer Mode patch
XenHat 9ef9a84
fix detectabledb import
XenHat f93d393
Add workaround for dolphin and dolphin-emu
XenHat 88e1b34
move fixup for Zenless Zone Zero
XenHat 70d0272
Remove Red Dead Online from the DB
XenHat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,14 @@ | ||
| import { readdir, readFile } from "fs/promises"; | ||
| import { readdir, readFile, readlink } from "fs/promises"; | ||
|
|
||
| export const getProcesses = async () => (await Promise.all( | ||
| (await readdir("/proc")).map(pid => | ||
| (+pid > 0) && readFile(`/proc/${pid}/cmdline`, 'utf8') | ||
| .then(path => [+pid, path.split("\0")[0], path.split("\0").slice(1)], () => 0) | ||
| .then(async path => { | ||
| let cwdPath; | ||
| try { | ||
| cwdPath = await readlink(`/proc/${pid}/cwd`); | ||
| } catch (err) {}; | ||
| return [+pid, path.split("\0")[0], path.split("\0").slice(1), cwdPath] | ||
| }, () => 0) | ||
| ) | ||
| )).filter(x => x); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we refactor this file to something like this?
https://jsfiddle.net/jsq76fyc/ <-- much easier to reason about than quadruple nested
ifblocks 🙂Then you can also keep the file minimal and export the methods outside of index.js to keep it sane for the mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This turned out to break detection again, so I'll need more time to fiddle with it.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@XenHat the approach I'd use for major refactors like this is:
Much easier in the long run to maintain it this way. Plus you can abstract the tests from actual OS/processes via fakes or mocks.
If I'd have some time I'll give you an example how to write tests for these. But it seems the maintainer didn't add any testing framework for this repo 🙂
So I guess we'd have to ask whether or not we should. E.g. jest/vitest @CanadaHonk