1.1.0 • Published 8 years ago

node-steam-shortcuts v1.1.0

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

node-steam-shortcuts

Parse and build shortcuts.vdf files to manage Non-Steam Games in Valve's Steam-Client

Examples

Builder example

var Builder=require("node-steam-shortcuts").Builder;
var fs=require("fs");

var shortcuts=Builder.build([
  {
    appname: "A Non-Steam Game",
    exe: "C:\\Games\\NonSteamGame\\game.exe",
    StartDir: "C:\\Games\\NonSteamGame",
    tags: ["favorite","RPG","Dragons"]
  },
  {
    appname: "An other Non-Steam Game",
    exe: "C:\\Games\\NonSteamGame2\\game.exe",
    StartDir: "C:\\Games\\NonSteamGame2",
    tags: ["Racing","Arcade"]
  }
]);
fs.writeFile("shortcuts.vdf",shortcuts,function(err){
  if(err){
    return console.error("oops:",err);
  }
  console.log("done!");
});

Parser example

var fs=require("fs");
var Parser=require("node-steam-shortcuts").Parser;

//Let's read the file we wrote in the builder example
fs.readFile("shortcuts.vdf",function(err,shortcuts){
  if(err){
    return console.error("oops:",err);
  }
  shortcuts=Parser.parse(shortcuts).toJSON();
  console.log(shortcuts.length);  //2
  console.log(shortcuts[0].appname);  //"A Non-Steam Game"
  console.log(shortcuts[0].tags); //["favorite","RPG","Dragons"]
});

Documentation

Shortcut(properties)

Creates a new Shortcut-Object.

Arguments

  • properties
    • appname - A string. The name of the Non-Steam Game. Default "".
    • exe - A String. The absolute path to the executable of the Non-Steam Game. Default "".
    • StartDir - A string. The absolute path to the working directory for the Non-Steam Game. Usually the directory where the executable resides. Default "".
    • icon - A string. The absolute path to a file containing the icon for the Non-Steam Game. If empty, the icon of the executable will be used. Default "".
    • ShortcutPath - A string. Purpose unknown. Default "".
    • hidden - A boolean. Determines if the Non-Steam Game shall be hidden in the Client. Does not seem to work though. Default false.
    • tags - An array of strings. Contains the tags associated with the Non-Steam Game. Default [].
var Shortcut=require("node-steam-shortcuts").Shortcut;
var shortcut=new Shortcut({
  appname: "A Non-Steam Game",
  exe: "C:\\Games\\NonSteamGame\\game.exe",
  StartDir: "C:\\Games\\NonSteamGame",
  tags: ["favorite","RPG","Dragons"]
});

Properties

Additionally to the properties provided in the arguments, there is also:

  • favorite - A boolean. Indicates whether or not the Non-Steam Game is listed with the Favorites.
shortcut.appname="A fancier name";
shortcut.favorite=false;  //removes the tag "favorite" from the tags-array

Functions

addTags(tags)/addTag(tag)

Adds one ore more tags to the shortcut. Both functions are identical.

Arguments
  • tags: A string or an array of strings.

removeTags(tags)/removeTag(tag)

Removes one or more tags from the shortcut. Both functions are identical.

Arguments
  • tags: A string or an array of strings.

getSHA1()

Returns an SHA1-Hash of this shortcut. This value is only dependent on the exe property.

toJSON()

Returns a JSON-Object that describes the Shortcut-Object.

ShortcutCollection(shortcutCollection)

Creates a new ShortcutCollection-Object. A ShortcutCollection is a Set of Shortcuts. A ShortcutCollection can not contain two Shortcuts with the same SHA1-Hash.

Arguments

  • shortcutCollection - A Shortcut or an object describing a Shortcut or an array of Shortcutss and/or of objects describing Shortcuts.
var Shortcut=require("node-steam-shortcuts").Shortcut;
var ShortcutCollection=require("node-steam-shortcuts").ShortcutCollection;
var shortcut={
  appname: "A Game",
  exe: "C:\\Games\\NonSteamGame\\game.exe"
};
var shortcuts=new ShortcutCollection(shortcut);
//OR
shortcuts=new ShortcutCollection(new Shortcut(shortcut));
//OR
shortcuts=new ShortcutCollection([shortcut]);
//OR
shortcuts=new ShortcutCollection([new Shortcut(shortcut)]);

Functions

addShortcuts(shortcuts)/addShortcut(shortcut)

Adds one ore more shortcuts to the collection. Both functions are identical.

Arguments
  • shortcuts: A Shortcutor an object describing a Shortcut or an array of Shortcuts and/or of objects describing Shortcuts
toJSON()

Returns a JSON-Object that describes the ShortcutCollection-Object.

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago