Codacy update for localize.js
This commit is contained in:
@ -26,11 +26,11 @@ locales.forEach(locale => {
|
|||||||
if (locData.hasOwnProperty(snippetName)) {
|
if (locData.hasOwnProperty(snippetName)) {
|
||||||
if (locData[snippetName].hash !== snippetHash) {
|
if (locData[snippetName].hash !== snippetHash) {
|
||||||
existingData =
|
existingData =
|
||||||
existingData.indexOf(' => ' + snippetHash) !== -1
|
existingData.indexOf(` => ${snippetHash}`) !== -1
|
||||||
? existingData
|
? existingData
|
||||||
: existingData.replace(
|
: existingData.replace(
|
||||||
locData[snippetName].hash,
|
locData[snippetName].hash,
|
||||||
locData[snippetName].hash + ' => ' + snippetHash
|
`${locData[snippetName].hash} => ${snippetHash}`
|
||||||
);
|
);
|
||||||
hashChanges.push({
|
hashChanges.push({
|
||||||
snippetName,
|
snippetName,
|
||||||
@ -44,39 +44,20 @@ locales.forEach(locale => {
|
|||||||
'comments': [${(snippets[snippet].match(COMMENT_REGEX) || []).map(
|
'comments': [${(snippets[snippet].match(COMMENT_REGEX) || []).map(
|
||||||
v => '`' + v.replace(/`/g, '\\`') + '`'
|
v => '`' + v.replace(/`/g, '\\`') + '`'
|
||||||
)}],
|
)}],
|
||||||
'hash': '${snippetHash}'
|
'hash': '${snippetHash}'\n}`);
|
||||||
}`);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!fs.existsSync(path.join(LOCALE_PATH, locale + '.js')) || !existingData.length)
|
if (!fs.existsSync(path.join(LOCALE_PATH, locale + '.js')) || !existingData.length)
|
||||||
existingData = `module.exports = {
|
existingData = `module.exports = {
|
||||||
'locale': {
|
'locale': {
|
||||||
'locale': '${locale}'
|
'locale': '${locale}'\n}};`;
|
||||||
}};`;
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(LOCALE_PATH, locale + '.js'),
|
path.join(LOCALE_PATH, locale + '.js'),
|
||||||
newData.length ? `${existingData.trim().slice(0, -2)},${newData.join(',')}};` : existingData
|
newData.length ? `${existingData.trim().slice(0, -2)},${newData.join(',')}};` : existingData
|
||||||
);
|
);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
path.join(LOCALE_PATH, locale + '_log'),
|
path.join(LOCALE_PATH, locale + '_log'),
|
||||||
`${new Date()}
|
`${new Date()}\nHash changes: ${hashChanges.length}\n${
|
||||||
Hash changes: ${hashChanges.length}
|
hashChanges.length ? hashChanges.map(v => `Snippet name: ${v.snippetName}\n Old hash: ${v.oldHash}\n New hash: ${v.newHash}\n`).join('\n'): ''}`
|
||||||
|
|
||||||
${
|
|
||||||
hashChanges.length
|
|
||||||
? hashChanges
|
|
||||||
.map(
|
|
||||||
v =>
|
|
||||||
'Snippet name:' +
|
|
||||||
v.snippetName +
|
|
||||||
'\n Old hash: ' +
|
|
||||||
v.oldHash +
|
|
||||||
'\n New hash: ' +
|
|
||||||
v.newHash +
|
|
||||||
'\n'
|
|
||||||
)
|
|
||||||
.join('\n')
|
|
||||||
: ''
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user