Scripts linted

This commit is contained in:
Angelos Chalaris
2018-08-03 10:49:29 +03:00
parent 37da7ac424
commit d9593cdce5
13 changed files with 525 additions and 233 deletions

View File

@ -7,7 +7,7 @@ const fs = require('fs-extra'),
path = require('path'),
chalk = require('chalk');
const util = require('./util');
if(util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
console.log(`${chalk.green('NOBUILD')} Tagging terminated, parent commit is a Travis build!`);
process.exit(0);
}
@ -28,11 +28,10 @@ console.time('Tagger');
snippets = util.readSnippets(snippetsPath);
// Load tag data from the database
tagDbData = util.readTags();
tagDbStats = Object.entries(tagDbData)
.reduce((acc, val) => {
val[1].forEach(v => acc.hasOwnProperty(v) ? acc[v]++ : (acc[v] = 1));
return acc;
}, {});
tagDbStats = Object.entries(tagDbData).reduce((acc, val) => {
val[1].forEach(v => (acc.hasOwnProperty(v) ? acc[v]++ : (acc[v] = 1)));
return acc;
}, {});
// Update the listing of snippets in tag_database and log the statistics, along with missing scripts
try {
for (let snippet of Object.entries(snippets))
@ -40,7 +39,9 @@ try {
tagDbData.hasOwnProperty(snippet[0].slice(0, -3)) &&
tagDbData[snippet[0].slice(0, -3)].join(',').trim()
)
output += `${snippet[0].slice(0, -3)}:${tagDbData[snippet[0].slice(0, -3)].join(',').trim()}\n`;
output += `${snippet[0].slice(0, -3)}:${tagDbData[snippet[0].slice(0, -3)]
.join(',')
.trim()}\n`;
else {
output += `${snippet[0].slice(0, -3)}:uncategorized\n`;
missingTags++;
@ -55,7 +56,9 @@ try {
}
// Log statistics for the tag_database file
console.log(`\n${chalk.bgWhite(chalk.black('=== TAG STATS ==='))}`);
for (let tagData of Object.entries(tagDbStats).filter(v => v[0] !== 'undefined').sort((a,b) => a[0].localeCompare(b[0])))
for (let tagData of Object.entries(tagDbStats)
.filter(v => v[0] !== 'undefined')
.sort((a, b) => a[0].localeCompare(b[0])))
console.log(`${chalk.green(tagData[0])}: ${tagData[1]} snippets`);
console.log(
`${chalk.blue("New untagged snippets (will be tagged as 'uncategorized'):")} ${missingTags}\n`