unsteam-path
v0.0.1
Published
Get steam path/game path in YOUR environment
Maintainers
Readme
This library only use pure javascript(or ts) and not dependent on any other environment.
Usage
- First get steam install path.
It provide a command for windows cmd. Use it like this:
import { x } from 'tinyexec'
import {
GET_STEAM_INSTALL_PATH_COMMAND,
getSteamPathFromCmdOutput
} from 'unsteam-path'
const [cmd, ...args] = GET_STEAM_INSTALL_PATH_COMMAND.split(' ')
const { stdout: output } = await x(cmd, args)
const steamPath = getSteamPathFromCmdOutput(output)tinyexec is a tiny executer library for nodejs, which can be replaced by any other executer.
- Get game path by id
// import { readFileSync } from 'node:fs'
import { readFile } from 'node:fs/promises'
import { getGamePath } from 'unsteam-path'
getGamePath(
550,
/* you have got it in the above example */
steamPath,
path => readFile(path, 'utf-8')
)// SteamLibrary/steamapps/common/Left 4 Dead 2readfile can be replaced by any other filesystem reader, which receive a path and return a text content.
You can also use a async fs reader here, and getGamePath will be a async function too.
