Script cleanup
This commit is contained in:
@ -8,9 +8,7 @@ const path = require('path');
|
|||||||
const chalk = require('chalk');
|
const chalk = require('chalk');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
if (
|
if (
|
||||||
util.isTravisCI() &&
|
util.isTravisCI() && util.isNotTravisCronOrApi()
|
||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
|
|
||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
|
|
||||||
) {
|
) {
|
||||||
console.log(
|
console.log(
|
||||||
`${chalk.green('NOBUILD')} Module build terminated, not a cron job or a custom build!`
|
`${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 chalk = require('chalk');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
if (
|
if (
|
||||||
util.isTravisCI() &&
|
util.isTravisCI() && util.isNotTravisCronOrApi()
|
||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'cron' &&
|
|
||||||
process.env['TRAVIS_EVENT_TYPE'] !== 'api'
|
|
||||||
) {
|
) {
|
||||||
console.log(`${chalk.green('NOBUILD')} Testing terminated, not a cron job or a custom build!`);
|
console.log(`${chalk.green('NOBUILD')} Testing terminated, not a cron job or a custom build!`);
|
||||||
process.exit(0);
|
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));
|
str.slice(0, 1).toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1));
|
||||||
// Checks if current environment is Travis CI
|
// Checks if current environment is Travis CI
|
||||||
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
|
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.
|
// Creates a hash for a value using the SHA-256 algorithm.
|
||||||
const hashData = val =>
|
const hashData = val =>
|
||||||
crypto
|
crypto
|
||||||
|
|||||||
@ -39,6 +39,13 @@ const unescapeHTML = str =>
|
|||||||
'"': '"'
|
'"': '"'
|
||||||
}[tag] || tag)
|
}[tag] || tag)
|
||||||
);
|
);
|
||||||
|
const filterSnippets = (snippetList, excludedFiles) =>
|
||||||
|
Object.keys(snippetList)
|
||||||
|
.filter(key => !excludedFiles.includes(key))
|
||||||
|
.reduce((obj, key) => {
|
||||||
|
obj[key] = snippetList[key];
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
if (
|
if (
|
||||||
util.isTravisCI() &&
|
util.isTravisCI() &&
|
||||||
/^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE']) &&
|
/^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE']) &&
|
||||||
@ -241,14 +248,7 @@ try {
|
|||||||
archivedOutput += `${archivedStartPart}\n`;
|
archivedOutput += `${archivedStartPart}\n`;
|
||||||
|
|
||||||
// Filter README.md from folder
|
// Filter README.md from folder
|
||||||
const excludeFiles = ['README.md'];
|
const filteredArchivedSnippets = filterSnippets(archivedSnippets, ['README.md']);
|
||||||
|
|
||||||
const filteredArchivedSnippets = Object.keys(archivedSnippets)
|
|
||||||
.filter(key => !excludeFiles.includes(key))
|
|
||||||
.reduce((obj, key) => {
|
|
||||||
obj[key] = archivedSnippets[key];
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
// Generate archived snippets from md files
|
// Generate archived snippets from md files
|
||||||
for (let snippet of Object.entries(filteredArchivedSnippets))
|
for (let snippet of Object.entries(filteredArchivedSnippets))
|
||||||
@ -314,14 +314,7 @@ try {
|
|||||||
glossaryOutput += `${glossaryStartPart}\n`;
|
glossaryOutput += `${glossaryStartPart}\n`;
|
||||||
|
|
||||||
// Filter README.md from folder
|
// Filter README.md from folder
|
||||||
const excludeFiles = ['README.md'];
|
const filteredGlossarySnippets = filterSnippets(glossarySnippets, ['README.md']);
|
||||||
|
|
||||||
const filteredGlossarySnippets = Object.keys(glossarySnippets)
|
|
||||||
.filter(key => !excludeFiles.includes(key))
|
|
||||||
.reduce((obj, key) => {
|
|
||||||
obj[key] = glossarySnippets[key];
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
// Generate glossary snippets from md files
|
// Generate glossary snippets from md files
|
||||||
for (let snippet of Object.entries(filteredGlossarySnippets))
|
for (let snippet of Object.entries(filteredGlossarySnippets))
|
||||||
|
|||||||
Reference in New Issue
Block a user