-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
48 lines (39 loc) · 1.34 KB
/
example.js
File metadata and controls
48 lines (39 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import path from "path";
import os from "os";
import { getSteamUsers, getAllSteamGames } from "./dist/index.js";
(async () => {
// Guess a default Steam path based on OS
const steamPath = (() => {
switch (os.platform()) {
case "win32":
return "C:\\Program Files (x86)\\Steam";
case "darwin":
return path.join(os.homedir(), "Library", "Application Support", "Steam");
case "linux":
default:
return path.join(os.homedir(), ".steam", "steam");
}
})();
console.log(`\nUsing Steam path: ${steamPath}\n`);
// Fetch user IDs from the Steam install
const users = await getSteamUsers(steamPath);
if (!users.length) {
console.error("❌ No Steam users found.");
process.exit(1);
}
// Use the first user found
const user = users[0];
console.log(`→ Using user: ${user.name} (ID: ${user.id})\n`);
// Fetch all games (Steam + non-Steam)
const { steamGames, nonSteamGames, all } = await getAllSteamGames(steamPath, user.id);
// Output results
console.log(`✅ Found ${steamGames.length} installed Steam game(s):`);
steamGames.forEach((game) => {
console.log(`- [Steam] ${game.name} (${game.appId})`, game);
});
console.log(`\n✅ Found ${nonSteamGames.length} non-Steam game(s):`);
nonSteamGames.forEach((game) => {
console.log(`- [Shortcut] ${game.name}`, game);
});
console.log(`\n🎮 Total games: ${all.length}`);
})();