Skip to content

Commit

Permalink
all working exceptp deub ally enemy for some reason?
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostboats committed Jul 17, 2024
1 parent 7499f5a commit 02297b9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions commands/organizeDataFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ function sortEntriesInFile(filePath, sortEntireEntries) {
const lines = entry.split(/(?:\r\n|\r|\n)/).filter(line => line.trim() !== '');
const newEntry = lines.shift(); // Extract "new entry" line
const typeLine = lines.shift(); // Extract "type" line
const dataLines = lines.sort(); // Sort data lines alphabetically
let usingLine = '';
const dataLines = lines.filter(line => {
if (line.startsWith('using ')) {
usingLine = line;
return false;
}
return true;
}).sort(); // Sort data lines alphabetically

if (sortEntireEntries) {
return `${newEntry}\r\n${typeLine}\r\n${dataLines.join('\r\n')}`;
return `${newEntry}\r\n${typeLine}\r\n${usingLine ? usingLine + '\r\n' : ''}${dataLines.join('\r\n')}`;
} else {
return `new entry ${newEntry}\r\n${typeLine}\r\n${dataLines.join('\r\n')}`;
return `new entry ${newEntry}\r\n${typeLine}\r\n${usingLine ? usingLine + '\r\n' : ''}${dataLines.join('\r\n')}`;
}
});

Expand Down

0 comments on commit 02297b9

Please sign in to comment.