-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
95 lines (77 loc) · 2.45 KB
/
index.js
File metadata and controls
95 lines (77 loc) · 2.45 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
const fs = require('fs');
const path = require('path');
const args = process.argv.slice(2);
function createUniqueFolder(baseFolderPath) {
// Define the initial folder name
let folderName = path.basename(baseFolderPath);
let dirPath = path.dirname(baseFolderPath);
let newFolderPath = baseFolderPath;
let count = 1;
// Check if the folder already exists
while (fs.existsSync(newFolderPath)) {
// Create a new folder name by appending a counter
newFolderPath = path.join(dirPath, `${folderName} #${count}`);
count++;
}
// Create the new folder
fs.mkdirSync(newFolderPath);
return newFolderPath;
}
const FoldersToCreate = [
{
name: "images",
files: [ {name: "characters"} ],
}, {
name: "data",
files: [
{
name: "dialogue",
files: [ {name: "boxes"}, {name: "characters"} ],
},
{name: "characters"}, {name: "stages"}, {name: "states"}, {name: "notes"}, {name: "splashes"}, {name: "config"}, {name: "titlescreen"}, {name: "weeks"},
],
}, { name: "songs" },
{ name: "music" },
{ name: "sounds" },
{ name: "fonts" },
{ name: "shaders" },
{ name: "videos", },
{ name: "ndlls" },
];
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
const TEMPLATE_NAME = "Template Mod By ItsLJcool";
const README =
`
Hi! Thanks for using Codename Engine Template Mod Generator!
This is a template mod that you can use to create your own mods. It contains all the files you need to get started.
Visit the [CNE Wiki](https://codename-engine.com/) to see all the uses for these files!
`
function main() {
let path = args[0];
if (path == undefined) path = __dirname;
path = createUniqueFolder(`${path}/${TEMPLATE_NAME}`);
for (const folder of FoldersToCreate) {
createFolderRecursive(path, folder);
}
fs.writeFileSync(`${path}/README.md`, README, 'utf8');
// await sleep(2000);
}
function createFolderRecursive(path, data) {
const folderPath = `${path}/${data.name}/`;
if (!fs.existsSync(folderPath)) {
try {
fs.mkdirSync(folderPath);
} catch (error) {
console.error(error);
process.exit();
return;
}
}
if (data.files == undefined) return;
for (const file of data.files) {
createFolderRecursive(folderPath, file);
}
}
main();