Skip to content

Commit

Permalink
feat: create a script to sort .local.dic
Browse files Browse the repository at this point in the history
Resolves #226 .
  • Loading branch information
MrChocolatine committed Feb 15, 2024
1 parent 2fe8c40 commit 1d08654
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .local.dic
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ npm
NVDA
ok
onboarding
one-to-one
one-to-many
one-to-one
Orca
outputPaths
owner/nombrable
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"preinstall": "node scripts/preinstall.mjs",
"build": "ember build --environment=production",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"lint:fix:local-dic": "node scripts/lint:fix:local-dic.mjs",
"lint:md": "remark . --frail",
"start": "ember serve",
"test:ember": "ember test",
Expand Down
24 changes: 24 additions & 0 deletions scripts/lint:fix:local-dic.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

import fs from 'fs';

/**
* Relative to the root of the project
*/
const DICTIONARY_FILE = '.local.dic';

// Retrieve content of the file
const fileContent = fs.readFileSync(DICTIONARY_FILE, 'utf8');
const fileContentLines = fileContent.split('\n');

// Remove duplicate and empty lines
const uniquesLines = [...new Set(fileContentLines)].filter(Boolean);

// Sort lines
const sortedLines = [...uniquesLines].sort((a, b) => a.localeCompare(b));

// Make sure to have a blank last line
sortedLines.push('');

// Rewrite existing file
fs.writeFileSync(DICTIONARY_FILE, sortedLines.join('\n'));

0 comments on commit 1d08654

Please sign in to comment.