mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-24 15:08:37 +02:00
feat: show unused key
This commit is contained in:
parent
8eaa9f285c
commit
77bd782e5b
2 changed files with 11 additions and 6 deletions
|
@ -6,23 +6,28 @@ var { strings } = require('../intl/strings');
|
|||
|
||||
var easyRegex = /intl\.str\(\s*'([a-zA-Z\-]+)'/g;
|
||||
|
||||
var goodKeys = 0;
|
||||
var allKetSet = new Set(Object.keys(strings));
|
||||
allKetSet.delete('error-untranslated'); // used in ./index.js
|
||||
|
||||
var goodKeySet = new Set();
|
||||
var validateKey = function(key) {
|
||||
if (!strings[key]) {
|
||||
console.log('NO KEY for: "', key, '"');
|
||||
} else {
|
||||
goodKeys++;
|
||||
goodKeySet.add(key);
|
||||
allKetSet.delete(key);
|
||||
}
|
||||
};
|
||||
|
||||
if (!util.isBrowser()) {
|
||||
util.readDirDeep(join(__dirname, '../..')).forEach(function(path) {
|
||||
util.readDirDeep(join(__dirname, '../../')).forEach(function(path) {
|
||||
var content = readFileSync(path);
|
||||
var match;
|
||||
while (match = easyRegex.exec(content)) {
|
||||
console.log(match[1])
|
||||
validateKey(match[1]);
|
||||
}
|
||||
});
|
||||
console.log(goodKeys + ' good keys found!');
|
||||
console.log(goodKeySet.size, ' good keys found!');
|
||||
console.log(allKetSet.size, ' keys did not use!');
|
||||
console.log(allKetSet);
|
||||
}
|
||||
|
|
|
@ -71,4 +71,4 @@ exports.readDirDeep = function(dir) {
|
|||
}
|
||||
});
|
||||
return paths;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue