From 3f69f489a14b2dc43d085143866e6253914eff97 Mon Sep 17 00:00:00 2001
From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>
Date: Wed, 10 Jan 2024 15:33:56 +0100
Subject: [PATCH] fix handling empty files
---
assets/analyzer.js | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/assets/analyzer.js b/assets/analyzer.js
index 38ee3e4..547ac4e 100644
--- a/assets/analyzer.js
+++ b/assets/analyzer.js
@@ -14,6 +14,7 @@ let cmdsBehindExecute = {}
let cmdsBehindMacros = {}
let comments = 0
let empty = 0
+let emptyFiles = []
let dpExclusive = {
folders: {
advancements: 0,
@@ -92,6 +93,7 @@ async function processEntries(entries) {
const processFile = result => {
done++
+ if (result.trim() == "") return emptyFiles.push(filePath)
if (!rpMode && ext == "mcfunction") {
const funcLocation = /data\/([-a-z0-9_.]+)\/functions\/([-a-z0-9_./]+)\.mcfunction/i.exec(filePath)
@@ -208,7 +210,7 @@ async function processEntries(entries) {
}
}
- if (entry.content) processFile(entry.content)
+ if ("content" in entry) processFile(entry.content)
else {
const reader = new FileReader()
if (ext == "png") reader.readAsDataURL(entry)
@@ -256,6 +258,7 @@ async function mainScan(hasData = false) {
cmdsBehindMacros = {}
comments = 0
empty = 0
+ emptyFiles = []
dpExclusive = {
folders: {
advancements: 0,
@@ -383,6 +386,11 @@ async function mainScan(hasData = false) {
missingFunctions.map(func => "" + func + "
").join("") +
"
"
: "") +
+ (emptyFiles.length > 0 ?
+ "Empty files:
" +
+ emptyFiles.map(func => "" + func + "
").join("") +
+ "
"
+ : "") +
(dpExclusive.scoreboards > 0 ? "Scoreboards created: " + localize(dpExclusive.scoreboards) + "
" : "") +
(!rpMode && Object.values(dpExclusive.selectors).reduce((a, b) => a + b) != 0 ? "Selectors used:
" : "") +