sort-locale-file.js 274 B

123456789
  1. import fs from 'fs'
  2. const file = process.argv[2]
  3. if (!file) {
  4. console.error('Usage: node sort-locale-file.js <path>')
  5. process.exit(1)
  6. }
  7. const obj = JSON.parse(fs.readFileSync(file, 'utf8'))
  8. fs.writeFileSync(file, JSON.stringify(obj, Object.keys(obj).sort(), 2) + '\n')