Skip to content

Instantly share code, notes, and snippets.

@Zegnat Zegnat/steam.html_build.js
Last active Aug 29, 2015

Embed
What would you like to do?
Generate a list of applications installed through Steam.
'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
You can’t perform that action at this time.