Skip to content

[Fix] Sideloaded games on Windows #3562

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

Merged
merged 3 commits into from
Mar 9, 2024
Merged
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
8 changes: 6 additions & 2 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,10 @@ async function callRunner(
let bin = runner.bin
let fullRunnerPath = join(runner.dir, bin)

// macOS/Linux: `spawn`ing an executable in the current working directory
// requires a "./"
if (!isWindows) bin = './' + bin

// On Windows: Use PowerShell's `Start-Process` to wait for the process and
// its children to exit, provided PowerShell is available
if (shouldUsePowerShell === null)
Expand All @@ -1005,10 +1009,10 @@ async function callRunner(
'Start-Process',
`"\`"${fullRunnerPath}\`""`,
'-Wait',
'-ArgumentList',
argsAsString,
'-NoNewWindow'
]
if (argsAsString) commandParts.push('-ArgumentList', argsAsString)

bin = fullRunnerPath = 'powershell'
}

Expand Down
4 changes: 2 additions & 2 deletions src/backend/storeManagers/storeManagerCommon/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
LogPrefix,
logWarning
} from '../../logger/logger'
import { dirname } from 'path'
import { basename, dirname } from 'path'
import { constants as FS_CONSTANTS } from 'graceful-fs'
import i18next from 'i18next'
import {
Expand Down Expand Up @@ -220,7 +220,7 @@ export async function launchGame(
{
name: runner,
logPrefix: LogPrefix.Backend,
bin: executable,
bin: basename(executable),
dir: dirname(executable)
},
{
Expand Down
7 changes: 1 addition & 6 deletions src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,7 @@ function showItemInFolder(item: string) {

function splitPathAndName(fullPath: string): { dir: string; bin: string } {
const dir = dirname(fullPath)
let bin = basename(fullPath)
// On Windows, you can just launch executables that are in the current working directory
// On Linux, you have to add a ./
if (!isWindows) {
bin = './' + bin
}
const bin = basename(fullPath)
// Make sure to always return this as `dir, bin` to not break path
// resolution when using `join(...Object.values(...))`
return { dir, bin }
Expand Down