-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdev.js
More file actions
71 lines (57 loc) · 2.22 KB
/
dev.js
File metadata and controls
71 lines (57 loc) · 2.22 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
/* eslint-disable no-console */
const fs = require('fs')
const path = require('path')
function deleteDirectory(deletePath) {
fs.rmSync(deletePath, { recursive: true, force: true })
}
function copyDirectory(fromPath, toPath) {
// If the 'toPath' top level directory doesn't already exist, create it.
if (!fs.existsSync(toPath)) {
fs.mkdirSync(toPath)
}
// Loop through every folder and file in the 'fromPath'
fs.readdir(fromPath, (err, files) => {
files.forEach((file) => {
const filepath = path.join(fromPath, file)
// If the file is actually a file, copy it over
if (fs.statSync(filepath).isFile()) {
fs.copyFileSync(filepath, path.join(toPath, file))
console.log('Copied file: ', file)
}
// Otherwise, if it's a directory, create a new folder in the destination and recursively call
if (fs.statSync(filepath).isDirectory()) {
copyDirectory(filepath, path.join(toPath, file))
console.log('Copied folder: ', file)
}
// If neither a file or folder, it is an unknown entity and it should get ignored
})
})
}
// Dev Input
const projectName = 'Minecraft Bedrock Debug Screen'
const behaviorPack = path.join(path.dirname(__filename), 'Source Behavior Pack')
// const resourcePack = path.join(path.dirname(__filename), 'Source Resource Pack')
// Dev Output
const root = process.env.LOCALAPPDATA
const minecraftLocal =
'Packages\\Microsoft.MinecraftUWP_8wekyb3d8bbwe\\LocalState\\games\\com.mojang'
const devBehaviorPackLocation = path.join(
root,
minecraftLocal,
'development_behavior_packs',
projectName
)
// const devResourcePackLocation = path.join(
// root,
// minecraftLocal,
// 'development_resource_packs',
// projectName
// )
console.log('BP: ', devBehaviorPackLocation)
// console.log('RP: ', devResourcePackLocation)
// Remove all files in behavior/resource pack location to start from a clean slate
deleteDirectory(devBehaviorPackLocation)
// deleteDirectory(devResourcePackLocation)
// Copy files
copyDirectory(behaviorPack, devBehaviorPackLocation)
// copyDirectory(resourcePack, devResourcePackLocation)