-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-apps.ts
65 lines (56 loc) · 1.52 KB
/
update-apps.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { copy } from "https://deno.land/[email protected]/fs/copy.ts";
const appsDir = await getAppsDir();
const apps = [
{
Dir: "./src/GT2/",
Name: "GT2_DigitalSpeedo"
},
{
Dir: "./src/GT4/",
Name: "GT4_Digital"
},
{
Dir: "./src/Other/",
Name: "EngineStreamDebug"
},
{
Dir: "./src/Other/",
Name: "SimpleAnalogTach"
}
];
apps.forEach(app => copyApp(app, appsDir));
async function copyApp(app: App, destDir: string) {
const source = app.Dir + app.Name;
const dest = destDir + app.Name;
// Clear existing app
try {
console.log(`Removing ${dest}`);
await Deno.remove(dest, { recursive: true });
} catch (_) {
console.log(`${dest} does not exist`)
}
console.log(`Copying ${source} to ${destDir}`);
await copy(source, dest);
}
async function getAppsDir(): Promise<string> {
const configFile = "config";
const defaultAppsDir =
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\BeamNG.drive\\ui\\modules\\apps\\";
try {
const appsDir = await Deno.readTextFile("config");
return appsDir;
} catch (_) {
console.log("Config file doesn't exist.");
const appsDir =
prompt(
"Paste the path to your BeamNG.drive apps folder:",
defaultAppsDir,
) ?? defaultAppsDir;
await Deno.writeTextFile(configFile, appsDir);
return appsDir;
}
}
interface App {
Name: string;
Dir: string;
}