Skip to content

Commit aa446e3

Browse files
committed
Update compilation function
Include all dependencies by default, and rework compilation workflow.
1 parent a0f28e0 commit aa446e3

File tree

4 files changed

+239
-7
lines changed

4 files changed

+239
-7
lines changed

Diff for: .gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
# Compiled
2-
functions/
3-
mcscripts/
1+
node_modules
2+
3+
temp/
4+
dist/

Diff for: compile.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ const fs = require('fs');
1010
const cp = require('child_process');
1111
const glob = require('glob');
1212

13-
glob('data/mb/scripts/**/*.mcf', {}, (err, files) => {
13+
const rmdir = (folder) => { try { fs.rmdirSync(folder, { recursive: true }); } catch { } };
14+
15+
rmdir('dist');
16+
rmdir('temp');
17+
fs.cpSync('data/mb/funcs', 'temp/scripts', { recursive: true });
18+
glob('temp/scripts/**/*.mcf', {}, (err, files) => {
1419
if (err) throw err.name;
1520
files.forEach(file => {
1621
const outfile = file.replace('funcs', 'scripts').replace('.mcf', '.mcscript');
@@ -20,10 +25,18 @@ glob('data/mb/scripts/**/*.mcf', {}, (err, files) => {
2025
const outContent = inContent
2126
.replace(/\/\/.+$/gm, '') // remove comments
2227
.replace(/^( *)(?=[a-z])/gm, '$1/') // execute -> /execute
23-
.replace(/^_/gm, '') // _const -> const
28+
.replace(/^(\s*)_/gm, '$1') // _const -> const
2429
.replace(/ (?=\()/gm, '') // for (1,2) -> for(1,2)
2530
fs.writeFileSync(outfile, outContent);
2631
});
27-
cp.execSync('mcscript compile');
28-
fs.rmdirSync('data/mb/scripts', { recursive: true }); // comment out if inspecting intermediary `.mcscript` files is needed
32+
cp.execSync('npx mcscript compile');
33+
34+
// output folder
35+
fs.cpSync('temp/functions', 'dist/data/mb/function', { recursive: true });
36+
fs.cpSync('data/mb/structures', 'dist/data/mb/structure', { recursive: true });
37+
fs.copyFileSync('pack.mcmeta', 'dist/pack.mcmeta');
38+
39+
// cleanup
40+
rmdir('temp'); // comment out if inspecting intermediary `.mcscript` files is needed
41+
rmdir('data/mb/functions');
2942
});

Diff for: package-lock.json

+195
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@nixinova/musical-blocks",
3+
"version": "3.1",
4+
"description": "Musical Blocks / Block Party minigame in vanilla Minecraft",
5+
"author": "Nixinova (https://nixinova.com)",
6+
"private": true,
7+
"scripts": {
8+
"compile": "node compile"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/Nixinova/Musical-Blocks.git"
13+
},
14+
"license": "ISC",
15+
"bugs": {
16+
"url": "https://github.com/Nixinova/Musical-Blocks/issues"
17+
},
18+
"homepage": "https://www.nixinova.com/musical-blocks",
19+
"devDependencies": {
20+
"glob": "^8.1.0",
21+
"mcscript": "^0.2.3"
22+
}
23+
}

0 commit comments

Comments
 (0)