node-steam-shortcuts
v1.1.0
Published
Parse and build shortcuts.vdf files to manage Non-Steam Games in Valve's Steam-Client
Downloads
44
Readme
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. Defaultfalse
.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 Shortcut
s. A ShortcutCollection
can not contain two Shortcut
s with the same SHA1-Hash.
Arguments
shortcutCollection
- AShortcut
or an object describing aShortcut
or an array ofShortcuts
s and/or of objects describingShortcut
s.
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
: AShortcut
or an object describing aShortcut
or an array ofShortcut
s and/or of objects describingShortcut
s
toJSON()
Returns a JSON-Object that describes the ShortcutCollection
-Object.