ci fixes
This commit is contained in:
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const chalk = require('chalk');
|
||||||
const util = require('../util');
|
const util = require('../util');
|
||||||
|
|
||||||
const glossaryFiles = util.getFilesInDir('./glossary', false);
|
const glossaryFiles = util.getFilesInDir('./glossary', false);
|
||||||
|
|||||||
@ -12,11 +12,13 @@ const fileTitles = [];
|
|||||||
|
|
||||||
const getGlossaryTermMarkdownBlock = (fileName) => {
|
const getGlossaryTermMarkdownBlock = (fileName) => {
|
||||||
let fileContent = fs.readFileSync(fileName, 'utf8');
|
let fileContent = fs.readFileSync(fileName, 'utf8');
|
||||||
let title = fileContent.match(/###[^\n]*/)[0].replace('### ', '');
|
|
||||||
|
|
||||||
|
let title = fileContent.match(/###[^\n]*/)[0].replace('### ', '').trim();
|
||||||
|
// let description = fileContent.replace(title, '').trim();
|
||||||
fileTitles.push(title);
|
fileTitles.push(title);
|
||||||
|
|
||||||
return fileContent.trim() + "\n";
|
return fileContent.trim() + "\n";
|
||||||
}
|
};
|
||||||
|
|
||||||
const glossaryFilesContentReducer = (accumulator, currentFilename) => {
|
const glossaryFilesContentReducer = (accumulator, currentFilename) => {
|
||||||
// handle first array item
|
// handle first array item
|
||||||
@ -24,19 +26,19 @@ const glossaryFilesContentReducer = (accumulator, currentFilename) => {
|
|||||||
return getGlossaryTermMarkdownBlock(accumulator) + "\n" + getGlossaryTermMarkdownBlock(currentFilename);
|
return getGlossaryTermMarkdownBlock(accumulator) + "\n" + getGlossaryTermMarkdownBlock(currentFilename);
|
||||||
}
|
}
|
||||||
return accumulator + "\n" + getGlossaryTermMarkdownBlock(currentFilename);
|
return accumulator + "\n" + getGlossaryTermMarkdownBlock(currentFilename);
|
||||||
}
|
};
|
||||||
|
|
||||||
const getTermLinkMarkdownBlock = (termTitle) => {
|
const getTermLinkMarkdownBlock = (termTitle) => {
|
||||||
let anchor = util.getMarkDownAnchor(termTitle);
|
let anchor = util.getMarkDownAnchor(termTitle);
|
||||||
return `* [\`${termTitle}\`](#${anchor})` + "\n";
|
return `* [\`${termTitle}\`](#${anchor})` + "\n";
|
||||||
}
|
};
|
||||||
|
|
||||||
const glossaryTableOfContentsReducer = (accumulator, currentFile) => {
|
const glossaryTableOfContentsReducer = (accumulator, currentFile) => {
|
||||||
if (accumulator === fileTitles[0]) {
|
if (accumulator === fileTitles[0]) {
|
||||||
return getTermLinkMarkdownBlock(accumulator) + getTermLinkMarkdownBlock(currentFile);
|
return getTermLinkMarkdownBlock(accumulator) + getTermLinkMarkdownBlock(currentFile);
|
||||||
}
|
}
|
||||||
return accumulator + getTermLinkMarkdownBlock(currentFile);
|
return accumulator + getTermLinkMarkdownBlock(currentFile);
|
||||||
}
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fileContents = glossaryFiles.reduce(glossaryFilesContentReducer);
|
const fileContents = glossaryFiles.reduce(glossaryFilesContentReducer);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const getFilesInDir = (directoryPath, withPath, exclude = null) => {
|
|||||||
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
|
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Synchronously read all snippets and sort them as necessary (case-insensitive)
|
// Synchronously read all snippets and sort them as necessary (case-insensitive)
|
||||||
const readSnippets = snippetsPath => {
|
const readSnippets = snippetsPath => {
|
||||||
|
|||||||
Reference in New Issue
Block a user