forked from ConstellationStarStudio/Cosmos-Adventure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.js
More file actions
140 lines (124 loc) · 3.29 KB
/
run.js
File metadata and controls
140 lines (124 loc) · 3.29 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
const fs = require("node:fs")
const packs = {
bp: ["BP/"],
rp: ["RP/", "SKYPEDIA/resource_pack/"],
}
const names = {
"BP/": "cosmos_bp/",
"RP/": "cosmos_rp/",
"SKYPEDIA/resource_pack/": "cosmos_skypedia/",
}
const scripts = {
source: "BP/scripts/",
target: "cosmos_bp/scripts/"
}
const ui = {
source: "RP/ui/",
target: "cosmos_rp/ui/",
textures: "RP/textures/ui/",
textures_target: "cosmos_rp/textures/ui/"
}
const bp = {
source: "BP/",
target: "cosmos_bp/"
}
const skypedia = {
source: "SKYPEDIA/resource_pack/",
target: "cosmos_skypedia/"
}
const mc = process.env.LOCALAPPDATA + "/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/"
const bp_path = mc + "development_behavior_packs/"
const rp_path = mc + "development_resource_packs/"
function copy_scripts() {
fs.cpSync(
scripts.source,
bp_path + scripts.target,
{recursive:true}
)
console.log('\u001b[32m' + "Copied Scripts" + "\u001B[37m")
}
function copy_ui() {
fs.cpSync(
ui.source,
rp_path + ui.target,
{recursive:true}
)
fs.cpSync(
ui.textures,
rp_path + ui.textures_target,
{recursive:true}
)
console.log('\u001b[32m' + "Copied UI" + "\u001B[37m")
}
function copy_bp() {
fs.cpSync(
bp.source,
bp_path + bp.target,
{recursive:true}
)
console.log('\u001b[32m' + "Copied Behavior Pack" + "\u001B[37m")
}
function copy_skypedia() {
fs.cpSync(
skypedia.source,
rp_path + skypedia.target,
{recursive:true}
)
console.log('\u001b[32m' + "Copied Skypedia" + "\u001B[37m")
}
function copy() {
['bp', 'rp'].forEach(pack_type =>
packs[pack_type].forEach(pack =>
fs.cpSync(
pack,
eval(pack_type + '_path') + names[pack],
{recursive:true}
)
)
)
console.log('\u001b[32m' + "Finished Copying" + "\u001B[37m")
}
function clean() {
['bp', 'rp'].forEach(pack_type => {
const mc_path = eval(pack_type + '_path')
packs[pack_type].forEach(pack =>
clean_folder(mc_path + names[pack], pack)
)
})
console.log('\u001b[32m' + "Finished Cleaning" + '\u001B[37m')
}
function clean_folder(folder, reference) {
fs.readdirSync(folder).forEach(item => {
if (!fs.existsSync(reference + item)) {
fs.rmSync(folder + item, { recursive: true, force: true })
console.log('\u001B[31m' + "Removed " + folder + item + '\u001B[37m')
}
else if (fs.lstatSync(reference + item).isDirectory()) clean_folder(folder + item + '/', reference + item + '/')
})
}
function remove() {
['bp', 'rp'].forEach(pack_type =>
packs[pack_type].forEach(pack =>
fs.rmSync(eval(pack_type + '_path') + names[pack], { recursive: true, force: true })
)
)
}
if (process.argv[2] == 'reload') {
if (process.argv[3] == 'all') {
copy()
clean()
}
if (process.argv[3] == 'scripts') {
copy_scripts()
}
if (process.argv[3] == 'ui') {
copy_ui()
}
if (process.argv[3] == 'bp') {
copy_bp()
}
if (process.argv[3] == 'skypedia') {
copy_skypedia()
}
}
if (process.argv[2] == 'delete') remove()