code cleanup
This commit is contained in:
parent
78ef651ca7
commit
e8cd664965
8 changed files with 362 additions and 406 deletions
|
|
@ -27,7 +27,7 @@ function linkPrefix(compatData, prefixDir) {
|
|||
} catch {}
|
||||
}
|
||||
|
||||
function buildEnv({ game, wine, workdir, systemWine }) {
|
||||
function buildEnv({ game, wine }) {
|
||||
const env = { ...process.env }
|
||||
const isProton = wine && wine.type === 'proton'
|
||||
let prefixDir = game.prefix ? prefixPath(game.prefix) : null
|
||||
|
|
@ -46,14 +46,13 @@ function buildEnv({ game, wine, workdir, systemWine }) {
|
|||
env.SteamGameId = '0'
|
||||
env.WINEPREFIX = path.join(env.STEAM_COMPAT_DATA_PATH, 'pfx')
|
||||
env.PROTON_LOG_DIR = path.join(DIRS.DATA, 'logs')
|
||||
fs.mkdirSync(path.join(env.PROTON_LOG_DIR), { recursive: true })
|
||||
fs.mkdirSync(env.PROTON_LOG_DIR, { recursive: true })
|
||||
linkPrefix(env.STEAM_COMPAT_DATA_PATH, prefixDir)
|
||||
if (!fs.existsSync(env.STEAM_COMPAT_DATA_PATH)) {
|
||||
fs.mkdirSync(env.STEAM_COMPAT_DATA_PATH, { recursive: true })
|
||||
}
|
||||
} else if (!systemWine) {
|
||||
env.WINEPREFIX = prefixDir
|
||||
} else {
|
||||
// plain wine (system or imported build)
|
||||
env.WINEPREFIX = prefixDir
|
||||
}
|
||||
|
||||
|
|
@ -98,15 +97,7 @@ function latestLogPath(gameId) {
|
|||
function openLatestLog(gameId) {
|
||||
const logFile = latestLogPath(gameId)
|
||||
fs.mkdirSync(path.dirname(logFile), { recursive: true })
|
||||
// Keep only the latest run's log: truncate the file from the previous session
|
||||
// and clean up logs left by older versions (<id>-<timestamp>.log).
|
||||
try {
|
||||
for (const f of fs.readdirSync(path.dirname(logFile))) {
|
||||
if (f.startsWith(`${gameId}-`) && f.endsWith('.log') && f !== `${gameId}-latest.log`) {
|
||||
fs.rmSync(path.join(path.dirname(logFile), f), { force: true })
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
// 'w' truncates, so every session starts with a fresh log
|
||||
return fs.createWriteStream(logFile, { flags: 'w' })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue