Skip to content

Commit

Permalink
improve non steam shortcuts parser
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartondock committed Jun 27, 2024
1 parent 1520316 commit 0a440bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/lib/parsers/non-srm-shortcuts.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import * as steam from '../helpers/steam'
const shortcutsParser = require('steam-shortcut-editor');

import * as fs from 'fs';
import { VDF_Manager } from '../vdf-manager';
import { VDF_AddedItemsFile } from '../vdf-added-items-file';

export class NonSRMShortcutsParser implements GenericParser {

Expand All @@ -29,8 +31,10 @@ export class NonSRMShortcutsParser implements GenericParser {
for(let userdir of directories) {
const shortcutsPath = path.join(userdir,'config','shortcuts.vdf')
const addedItemsPath = path.join(userdir,'config','addedItemsV2.json')
const addedItems = fs.existsSync(addedItemsPath) ? JSON.parse(fs.readFileSync(addedItemsPath,'utf8')) : {};
const addedAppIds = Object.keys(addedItems.addedApps).filter(appId=>!addedItems.addedApps[appId].artworkOnly)
const vdfAddedItemsFile = new VDF_AddedItemsFile(addedItemsPath);
await vdfAddedItemsFile.read();
const { addedApps } = vdfAddedItemsFile.data;
const addedAppIds = Object.keys(addedApps).filter(appId=>!addedApps[appId].artworkOnly)
if(fs.existsSync(shortcutsPath)) {
const {shortcuts} = shortcutsParser.parseBuffer(fs.readFileSync(shortcutsPath));
const mappedApps = shortcuts.filter((shortcut: any) => {
Expand Down
1 change: 0 additions & 1 deletion src/renderer/services/parsers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export class ParsersService {
}

getKnownSteamDirectories() {
let preParser = new VariableParser({ left: '${', right: '}' });
let steamdirs = this.getUserConfigurationsArray().map(config => this.parseSteamDir(config.saved.steamDirectory)).filter(path => path!=="");
if(this.appSettings.environmentVariables.steamDirectory) {
steamdirs.push(this.appSettings.environmentVariables.steamDirectory)
Expand Down

0 comments on commit 0a440bb

Please sign in to comment.