Optimized scripts
This commit is contained in:
@ -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)
|
||||
|
||||
@ -9,9 +9,8 @@ const fs = require('fs-extra');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
// 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'])) {
|
||||
const util = require('./util');
|
||||
if(util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) {
|
||||
console.log(`${chalk.green('NOBUILD')} Linting terminated, parent commit is a Travis build!`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@ -6,9 +6,8 @@ const fs = require('fs-extra');
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
const chalk = require('chalk');
|
||||
// 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() && process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && process.env['TRAVIS_EVENT_TYPE'] !== 'api') {
|
||||
const util = require('./util');
|
||||
if(util.isTravisCI() && process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && process.env['TRAVIS_EVENT_TYPE'] !== 'api') {
|
||||
console.log(`${chalk.green('NOBUILD')} Module build terminated, not a cron job or a custom build!`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@ -7,9 +7,7 @@ const fs = require('fs-extra'),
|
||||
path = require('path'),
|
||||
chalk = require('chalk');
|
||||
const util = require('./util');
|
||||
// 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')} Tagging terminated, parent commit is a Travis build!`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@ -7,9 +7,8 @@
|
||||
const fs = require('fs-extra'), path = require('path');
|
||||
const child_process = require('child_process');
|
||||
const chalk = require('chalk');
|
||||
// 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() && process.env['TRAVIS_EVENT_TYPE'] !== 'cron' && process.env['TRAVIS_EVENT_TYPE'] !== 'api') {
|
||||
const util = require('./util');
|
||||
if(util.isTravisCI() && 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!`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ const readSnippets = snippetsPath => {
|
||||
}
|
||||
return snippets;
|
||||
}
|
||||
// Used in `readTags`
|
||||
// Creates an object from pairs
|
||||
const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {});
|
||||
// Load tag data from the database
|
||||
const readTags = () => {
|
||||
@ -64,4 +64,6 @@ const optimizeNodes = (data, regexp, replacer) => {
|
||||
// Capitalizes the first letter of a string
|
||||
const capitalize = (str, lowerRest = false) =>
|
||||
str.slice(0, 1).toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1));
|
||||
module.exports = {readSnippets, readTags, optimizeNodes, capitalize};
|
||||
// Checks if current environment is Travis CI
|
||||
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
|
||||
module.exports = {readSnippets, readTags, optimizeNodes, capitalize, objectFromPairs, isTravisCI};
|
||||
|
||||
@ -10,8 +10,6 @@ const fs = require('fs-extra'),
|
||||
minify = require('html-minifier').minify;
|
||||
const util = require('./util');
|
||||
var Prism = require('prismjs');
|
||||
// Load helper functions (these are from existing snippets in 30 seconds of code!)
|
||||
const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env;
|
||||
const unescapeHTML = str =>
|
||||
str.replace(
|
||||
/&|<|>|'|"/g,
|
||||
@ -24,7 +22,7 @@ const unescapeHTML = str =>
|
||||
'"': '"'
|
||||
}[tag] || tag)
|
||||
);
|
||||
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')} index build terminated, parent commit is a Travis build!`);
|
||||
process.exit(0);
|
||||
}
|
||||
@ -57,8 +55,6 @@ let snippets = {},
|
||||
endPart = '',
|
||||
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), {});
|
||||
// Start the timer of the script
|
||||
console.time('Webber');
|
||||
// Synchronously read all snippets and sort them as necessary (case-insensitive)
|
||||
|
||||
Reference in New Issue
Block a user