Skip to content

Commit

Permalink
fix handling empty files
Browse files Browse the repository at this point in the history
  • Loading branch information
DEVTomatoCake committed Jan 10, 2024
1 parent 81e7e15 commit 3f69f48
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion assets/analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let cmdsBehindExecute = {}
let cmdsBehindMacros = {}
let comments = 0
let empty = 0
let emptyFiles = []
let dpExclusive = {
folders: {
advancements: 0,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -256,6 +258,7 @@ async function mainScan(hasData = false) {
cmdsBehindMacros = {}
comments = 0
empty = 0
emptyFiles = []
dpExclusive = {
folders: {
advancements: 0,
Expand Down Expand Up @@ -383,6 +386,11 @@ async function mainScan(hasData = false) {
missingFunctions.map(func => "<span class='indented'>" + func + "</span><br>").join("") +
"<br>"
: "") +
(emptyFiles.length > 0 ?
"<strong>Empty files:</strong><br>" +
emptyFiles.map(func => "<span class='indented'>" + func + "</span><br>").join("") +
"<br>"
: "") +

(dpExclusive.scoreboards > 0 ? "<strong>Scoreboards created: " + localize(dpExclusive.scoreboards) + "</strong><br>" : "") +
(!rpMode && Object.values(dpExclusive.selectors).reduce((a, b) => a + b) != 0 ? "<strong>Selectors used:</strong><br>" : "") +
Expand Down

0 comments on commit 3f69f48

Please sign in to comment.