Skip to content

Instantly share code, notes, and snippets.

@josh-hemphill
Created October 21, 2021 02:54
Show Gist options
  • Save josh-hemphill/25f73281faf08f0be0ed72b2cd2aa1da to your computer and use it in GitHub Desktop.
Save josh-hemphill/25f73281faf08f0be0ed72b2cd2aa1da to your computer and use it in GitHub Desktop.
import { parse } from "https://deno.land/std@0.112.0/flags/mod.ts";
const HELP_TEXT = `
usage: this-file <steam username> <target steam library directory> [--no-verify]
usage (as script): deno run -A ./update-verify.ts <steam username> <target steam library directory> [--no-verify]
You can alternatively specify <username> and <library> with any alias. e.g.
-u <username>
--user <username>
--username <username>
--user=<username>
--username=<username>
and
-l <library>
--lib <library>
--library <library>
--lib=<library>
--library=<library>
You can also provide the --no-verify or -n flag to skip verification
`.replace(/\t/g, " ");
if (
["help", "-h", "--help", "/help", "\\help", "?", "-?"]
.includes(Deno.args[0]) ||
Deno.args.length === 0
) {
console.log(HELP_TEXT);
}
const parsed = parse(Deno.args, {
alias: {
"library": "l",
"lib": "l",
"user": "u",
"username": "u",
"no-verify": "n",
},
string: ["l", "u"],
boolean: ["n"],
});
const decoder = new TextDecoder();
/** Shorthand for new TextDecoder().decode() */
function decode(input?: Uint8Array): string {
return decoder.decode(input);
}
const present = (parsed.l && parsed.u);
let lib = parsed.l;
let user = parsed.u;
if (!present && Deno.args.length > 1) {
user = Deno.args[0];
lib = Deno.args[1];
} else {
console.log(HELP_TEXT);
Deno.exit(1);
}
const p = Deno.run({
cmd: [
"steamcmd",
"+force_install_dir",
lib,
"+login",
user,
"+apps_installed",
"+quit",
],
stdout: "piped",
});
await p.status();
const output = decode(await p.output());
const games = output.split("\n").filter((v) => v.startsWith("AppID")).map(
(v) => {
const cols = v.split(" : ");
return {
id: cols[0].split(" ")[1],
name: cols[1].slice(1, cols[1].length - 2),
dir: cols[2].replace(" \r", ""),
};
},
);
for (const game of games) {
await Deno.run({
cmd: [
"steamcmd",
"+force_install_dir",
lib,
"+login",
user,
"+app_update",
game.id,
parsed.n ? "" : "validate",
"+quit",
],
}).status();
}
@TimeToFixStuff
Copy link

Does this still work? I get errors in both windows and linux (under wsl):

D:\Apps\steamcmd>deno run -A steam-update-verify.ts username ....\Steam
error: Uncaught NotFound: program not found
const p = Deno.run({
^
at opRun (ext:runtime/40_process.js:46:14)
at Object.run (ext:runtime/40_process.js:132:15)
at file:///D:/Apps/steamcmd/steam-update-verify.ts:59:16

@josh-hemphill
Copy link
Author

This was always a bit flaky because of steamcmd being flaky, but it sounds like steamcmd isn't in your path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment