forked from ModDota/TypeScriptAddonTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
23 lines (20 loc) · 711 Bytes
/
utils.js
File metadata and controls
23 lines (20 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { findSteamAppByName, SteamNotFoundError } = require("find-steam-app");
const packageJson = require("../package.json");
module.exports.getAddonName = () => {
if (!/^[a-z][\d_a-z]+$/.test(packageJson.name)) {
throw new Error(
"Addon name may consist only of lowercase characters, digits, and underscores " +
"and should start with a letter. Edit `name` field in `package.json` file.",
);
}
return packageJson.name;
};
module.exports.getDotaPath = async () => {
try {
return await findSteamAppByName("dota 2 beta");
} catch (error) {
if (!(error instanceof SteamNotFoundError)) {
throw error;
}
}
};