Skip to content

Commit

Permalink
Change: do not copy keys, case sensitive compare
Browse files Browse the repository at this point in the history
  • Loading branch information
nichwall committed Jun 11, 2024
1 parent 90af59d commit c964713
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion copy_keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function saveJSONFile(filePath, data) {
}

function updateJSONFiles(baseFileName, directory) {
/*
const baseFilePath = path.join(directory, baseFileName);
const baseData = loadJSONFile(baseFilePath);
Expand All @@ -22,6 +23,7 @@ function updateJSONFiles(baseFileName, directory) {
.forEach(key => {
sortedBaseData[key] = baseData[key];
});
*/

fs.readdirSync(directory).forEach(filename => {
const filePath = path.join(directory, filename);
Expand All @@ -31,11 +33,12 @@ function updateJSONFiles(baseFileName, directory) {
// Check if keys are in alphabetical order
const keys = Object.keys(otherData);
for (let i = 1; i < keys.length; i++) {
if (keys[i].toLowerCase() < keys[i - 1].toLowerCase()) {
if (keys[i] < keys[i - 1]) {
throw new Error('Keys are not alphabetized in ' + filename);
}
}
}
/*
if (filename.endsWith('.json') && filename !== baseFileName) {
let otherData = loadJSONFile(filePath);
Expand Down Expand Up @@ -64,6 +67,7 @@ function updateJSONFiles(baseFileName, directory) {
saveJSONFile(filePath, sortedOtherData);
}
*/
});

}
Expand Down

0 comments on commit c964713

Please sign in to comment.