Optimized scripts

This commit is contained in:
Angelos Chalaris
2018-02-04 20:16:04 +02:00
parent c37df3ee82
commit 35eb0d1cb8
8 changed files with 15 additions and 27 deletions

View File

@ -11,13 +11,11 @@ const util = require('./util');
const SNIPPETS_PATH = './snippets';
const SNIPPETS_ARCHIVE_PATH = './snippets_archive';
const STATIC_PARTS_PATH = './static-parts';
// Load helper functions (these are from existing snippets in 30 seconds of code!)
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
if(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')} README build terminated, parent commit is a Travis build!`);
process.exit(0);
}
if(isTravisCI() && (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || process.env['TRAVIS_EVENT_TYPE'] === 'api')){
if(util.isTravisCI() && (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || process.env['TRAVIS_EVENT_TYPE'] === 'api')){
console.log(`${chalk.green('ARCHIVE')} Cron job or custom build, building archive README!`);
console.time('Builder');
let snippets = {};
@ -91,9 +89,6 @@ let startPart = '',
output = '',
tagDbData = {};
// Load helper functions (these are from existing snippets in 30 seconds of code!)
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
console.time('Builder');
// Synchronously read all snippets from snippets folder and sort them as necessary (case-insensitive)