Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool/unused i18n token finder #457

Closed
wants to merge 8 commits into from
Create i18n_results directory if needed when writing unused i18n toke…
…n checker output
  • Loading branch information
wlycdgr committed Oct 10, 2019
commit b20fd10ffc9422707c55513010369e6470bc6c13
@@ -23,9 +23,16 @@ const jsonfile = require('jsonfile');

// Constants
const DEFAULT_LOCALE_TOKENS_FILE = './_locales/en/messages.json';
const UNUSED_TOKENS_FILE = './tools/i18n_results/unused_tokens.txt';
const UNUSED_TOKENS_DIR = './tools/i18n_results';
const UNUSED_TOKENS_FILENAME = 'unused_tokens.txt';

function saveListOfUnusedTokensToFile(unusedTokens) {
const filepath = `${UNUSED_TOKENS_DIR}/${UNUSED_TOKENS_FILENAME}`;

if (!fs.existsSync(UNUSED_TOKENS_DIR)) {
fs.mkdirSync(UNUSED_TOKENS_DIR);
}

function saveListOfUnusedTokensToFile(filepath, unusedTokens) {
fs.writeFileSync(
filepath,
unusedTokens.join('\n')
@@ -96,7 +103,6 @@ function getJSONKeys(filepath) {
}

saveListOfUnusedTokensToFile(
UNUSED_TOKENS_FILE,
findUnusedTokens(
getJSONKeys(DEFAULT_LOCALE_TOKENS_FILE),
getFilepaths(
ProTip! Use n and p to navigate between commits in a pull request.