Script cleanup
This commit is contained in:
@ -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!`
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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))
|
||||
|
||||
Reference in New Issue
Block a user