This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
forked from i18nlaurel/Web3-Glossary
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plurals enabled; search functionality massively improved
- Loading branch information
1 parent
9ed7dd5
commit a11326a
Showing
5 changed files
with
4,025 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This script is used to sort terms.json in alphabetical order. | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const filePath = path.join(__dirname, 'terms.json'); | ||
|
||
// Read the JSON file | ||
fs.readFile(filePath, 'utf8', (err, data) => { | ||
if (err) { | ||
console.error('Error reading the file:', err); | ||
return; | ||
} | ||
|
||
// Parse the JSON data | ||
let termsData = JSON.parse(data); | ||
|
||
// Extract terms object | ||
let terms = termsData[0].terms; | ||
|
||
// Sort the terms alphabetically by the term key | ||
let sortedTerms = Object.keys(terms).sort().reduce((acc, key) => { | ||
acc[key] = terms[key]; | ||
return acc; | ||
}, {}); | ||
|
||
// Update the terms data with the sorted terms | ||
termsData[0].terms = sortedTerms; | ||
|
||
// Write the sorted JSON back to the file | ||
fs.writeFile(filePath, JSON.stringify(termsData, null, 2), 'utf8', (err) => { | ||
if (err) { | ||
console.error('Error writing the file:', err); | ||
return; | ||
} | ||
console.log('Terms sorted and saved successfully.'); | ||
}); | ||
}); |
Oops, something went wrong.