Script cleanup

This commit is contained in:
Angelos Chalaris
2018-09-22 13:29:27 +03:00
parent f97957778a
commit d353c83727
4 changed files with 13 additions and 22 deletions

View File

@ -8,9 +8,7 @@ const path = require('path');
const chalk = require('chalk');
const util = require('./util');
if (
util.isTravisCI() &&
process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
util.isTravisCI() && util.isNotTravisCronOrApi()
) {
console.log(
`${chalk.green('NOBUILD')} Module build terminated, not a cron job or a custom build!`

View File

@ -10,9 +10,7 @@ const childProcess = require('child_process');
const chalk = require('chalk');
const util = require('./util');
if (
util.isTravisCI() &&
process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
util.isTravisCI() && util.isNotTravisCronOrApi()
) {
console.log(`${chalk.green('NOBUILD')} Testing terminated, not a cron job or a custom build!`);
process.exit(0);

View File

@ -102,6 +102,8 @@ const capitalize = (str, lowerRest = false) =>
str.slice(0, 1).toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1));
// Checks if current environment is Travis CI
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
const isNotTravisCronOrAPI = () => process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
process.env['TRAVIS_EVENT_TYPE'] !== 'api';
// Creates a hash for a value using the SHA-256 algorithm.
const hashData = val =>
crypto

View File

@ -39,6 +39,13 @@ const unescapeHTML = str =>
'"': '"'
}[tag] || tag)
);
const filterSnippets = (snippetList, excludedFiles) =>
Object.keys(snippetList)
.filter(key => !excludedFiles.includes(key))
.reduce((obj, key) => {
obj[key] = snippetList[key];
return obj;
}, {});
if (
util.isTravisCI() &&
/^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE']) &&
@ -241,14 +248,7 @@ try {
archivedOutput += `${archivedStartPart}\n`;
// Filter README.md from folder
const excludeFiles = ['README.md'];
const filteredArchivedSnippets = Object.keys(archivedSnippets)
.filter(key => !excludeFiles.includes(key))
.reduce((obj, key) => {
obj[key] = archivedSnippets[key];
return obj;
}, {});
const filteredArchivedSnippets = filterSnippets(archivedSnippets, ['README.md']);
// Generate archived snippets from md files
for (let snippet of Object.entries(filteredArchivedSnippets))
@ -314,14 +314,7 @@ try {
glossaryOutput += `${glossaryStartPart}\n`;
// Filter README.md from folder
const excludeFiles = ['README.md'];
const filteredGlossarySnippets = Object.keys(glossarySnippets)
.filter(key => !excludeFiles.includes(key))
.reduce((obj, key) => {
obj[key] = glossarySnippets[key];
return obj;
}, {});
const filteredGlossarySnippets = filterSnippets(glossarySnippets, ['README.md']);
// Generate glossary snippets from md files
for (let snippet of Object.entries(filteredGlossarySnippets))