Last active
August 29, 2015 14:07
-
-
Save Zegnat/f4e10be7d02d48b23df6 to your computer and use it in GitHub Desktop.
Generate a list of applications installed through Steam.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var fs = require('fs'), path = require('path'), tilde = process.env.HOME, | |
SteamApps = tilde + '/Library/Application Support/Steam/SteamApps', | |
print = function (string) { return process.stdout.write(string + "\n"); }, | |
games = fs | |
.readdirSync(SteamApps) | |
.filter(function(file) { | |
return path.extname(file) === '.acf'; | |
}) | |
.map(function(file) { | |
file = path.join(SteamApps, file); | |
file = fs.readFileSync(file, {encoding: 'utf8'}); | |
// Hell: .acf to .json through several substitutions. | |
file = file.replace(/^(\s*"[^"]+")\s+/gm, '$1: '); | |
file = file.replace(/(["}](?!\s+}))$/gm, '$1,'); | |
file = JSON.parse('{' + file.slice(0, -2) + '}'); | |
return [ | |
file.AppState.name, | |
'http://store.steampowered.com/app/' + file.AppState.appID + '/' | |
]; | |
}) | |
.sort(function(a, b) { | |
return a[0].localeCompare(b[0]); | |
}); | |
print('<!doctype html>'); | |
print('<meta charset="utf-8" />'); | |
print('<title>Installed from Steam</title>'); | |
print('<h1>Installed from Steam</h1>'); | |
print('<ul>'); | |
games.forEach(function(game){ | |
print('<li><a href="' + game[1] + '">' + game[0] + '</a></li>'); | |
}); | |
print('</ul>'); | |
print('<small>Generated ' + (new Date()).toISOString() + '</small>'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment