forked from pedr0fontoura/fivem-appearance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.js
66 lines (50 loc) · 1.97 KB
/
release.js
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
66
const { promises: fs } = require("fs");
const path = require("path");
const RELEASE_PATH = path.resolve(__dirname, "release");
const RESOURCE_PATH = path.resolve(RELEASE_PATH, "fivem-appearance");
const FILES = ["fxmanifest.lua", "peds.json", "tattoos.json" , "README.md", "LICENSE"];
const TYPESCRIPT_BUILD_SRC = path.resolve(__dirname, "game", "dist");
const UI_BUILD_SRC = path.resolve(__dirname, "web", "dist");
const LOCALES_SRC = path.resolve(__dirname, "locales");
const TYPESCRIPT_BUILD_DEST = path.resolve(RESOURCE_PATH, "game", "dist");
const UI_BUILD_DEST = path.resolve(RESOURCE_PATH, "web", "dist");
const LOCALES_DEST = path.resolve(RESOURCE_PATH, "locales");
async function copyDir(src, dest) {
await fs.mkdir(dest, { recursive: true });
const entries = await fs.readdir(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
entry.isDirectory()
? await copyDir(srcPath, destPath)
: await fs.copyFile(srcPath, destPath);
}
}
async function execute() {
try {
await fs.access(RELEASE_PATH);
console.log("[fivem-appearance] Release folder exists");
console.log("[fivem-appearance] Removing release folder...");
await fs.rmdir(RELEASE_PATH, { recursive: true });
} catch (err) {
console.log(`[fivem-appearance] Release folder don't exist`);
}
console.log("[fivem-appearance] Creating release folder...");
await fs.mkdir(RESOURCE_PATH, { recursive: true });
console.log("[fivem-appearance] Copying files...");
await copyDir(TYPESCRIPT_BUILD_SRC, TYPESCRIPT_BUILD_DEST);
await copyDir(UI_BUILD_SRC, UI_BUILD_DEST);
await copyDir(LOCALES_SRC, LOCALES_DEST);
for (const file of FILES) {
try {
await fs.copyFile(
path.join(__dirname, file),
path.join(RESOURCE_PATH, file)
);
} catch (err) {
console.log(err);
}
}
console.log("[fivem-appearance] Release created!");
}
execute();