Cleanup for scripts folder

This commit is contained in:
Angelos Chalaris
2018-11-10 14:55:31 +02:00
parent c1fe403bf0
commit 869ca8c13e
10 changed files with 130 additions and 148 deletions

View File

@ -47,8 +47,7 @@ if (
// Store the data read from each snippet in the appropriate object
for (const name of snippetFilenames.filter(s => s !== 'README.md'))
snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8');
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
process.exit(1);
}
@ -70,8 +69,7 @@ if (
// Write to the README file of the archive
fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output);
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During README generation for snippets archive: ${err}`);
process.exit(1);
}
@ -110,8 +108,7 @@ snippets = util.readSnippets(SNIPPETS_PATH);
try {
startPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-start.md'), 'utf8');
endPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-end.md'), 'utf8');
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`);
process.exit(1);
}
@ -171,8 +168,7 @@ try {
output += `\n${endPart}\n`;
// Write to the README file
fs.writeFileSync('README.md', output);
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During README generation: ${err}`);
process.exit(1);
}

View File

@ -80,8 +80,7 @@ let listingData = {
meta: {
hash: v.meta.hash
}
}))
,
})),
meta: {
specification: 'http://jsonapi.org/format/'

View File

@ -41,9 +41,9 @@ const getTermLinkMarkdownBlock = termTitle => {
};
const glossaryTableOfContentsReducer = (accumulator, currentFile) => {
if (accumulator === fileTitles[0]) {
if (accumulator === fileTitles[0])
return getTermLinkMarkdownBlock(accumulator) + getTermLinkMarkdownBlock(currentFile);
}
return accumulator + getTermLinkMarkdownBlock(currentFile);
};

View File

@ -77,8 +77,7 @@ try {
console.log(`${chalk.green('SUCCESS!')} Snippet files linted!`);
console.timeEnd('Linter');
});
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During linting: ${err}`);
process.exit(1);
}

View File

@ -38,8 +38,7 @@ try {
output += `${snippet[0].slice(0, -3)}:${tagDbData[snippet[0].slice(0, -3)]
.join(',')
.trim()}\n`;
}
else {
} else {
output += `${snippet[0].slice(0, -3)}:uncategorized\n`;
missingTags++;
console.log(`${chalk.yellow('Tagged uncategorized:')} ${snippet[0].slice(0, -3)}`);
@ -47,8 +46,7 @@ try {
}
// Write to tag_database
fs.writeFileSync('tag_database', output);
}
catch (err) {
} catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During tag_database generation: ${err}`);
process.exit(1);

View File

@ -28,7 +28,7 @@ try {
const orphanedTests = [...definedTests.filter(v => ![...snippets, ...archivedSnippets].includes(v))];
orphanedTests.forEach(snippet => {
console.log(`${chalk.yellow('WARNING!')} Orphaned test: ${snippet}`);
})
});
// Create files for undefined tests
undefinedTests.forEach(snippet => {
const exportTest = [

View File

@ -32,8 +32,7 @@ const getFilesInDir = (directoryPath, withPath, exclude = null) => {
}, []);
}
return directoryFilenames;
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
process.exit(1);
}
@ -47,8 +46,7 @@ const readSnippets = snippetsPath => {
try {
for (let snippet of snippetFilenames)
snippets[snippet] = fs.readFileSync(path.join(snippetsPath, snippet), 'utf8');
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`);
process.exit(1);
}
@ -71,8 +69,7 @@ const readTags = () => {
return data;
})
);
}
catch (err) {
} catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During tag database loading: ${err}`);
process.exit(1);
@ -133,7 +130,7 @@ const getCodeBlocks = str => {
es6: results[0],
es5: babel.transformSync(results[0], { presets: ['@babel/preset-env'] }).code.replace('"use strict";\n\n', ''),
example: results[1]
}
};
};
// Gets the textual content for a snippet file.
const getTextualContent = str => {

View File

@ -109,8 +109,7 @@ sass.render(
if (!err2) console.log(`${chalk.green('SUCCESS!')} style.css file generated!`);
else console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
});
}
else
} else
console.log(`${chalk.red('ERROR!')} During style.css file generation: ${err}`);
}
@ -148,8 +147,7 @@ try {
'static-page-start.html',
'static-page-end.html'
].map(filename => fs.readFileSync(path.join(staticPartsPath, filename), 'utf8'));
}
catch (err) {
} catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`);
process.exit(1);
@ -234,14 +232,13 @@ try {
`${chalk.green('SUCCESS!')} ${page.tag === 'array' ? 'index' : page.tag}.html file generated!`
);
});
}
catch (err) {
} catch (err) {
// Handle errors (hopefully not!)
console.log(`${chalk.red('ERROR!')} During category page generation: ${err}`);
process.exit(1);
}
const generateMenuForStaticPage = (staticPart) => {
const generateMenuForStaticPage = staticPart => {
let taggedData = util.prepTaggedData(tagDbData);
// Add the start static part
let htmlCode;
@ -268,7 +265,7 @@ const generateMenuForStaticPage = (staticPart) => {
htmlCode += '</ul>\n';
}
return staticPart.replace('$nav-menu-data', htmlCode);
}
};
const staticPageStartGenerator = (staticPart, heading, description) => {
let taggedData = util.prepTaggedData(tagDbData);
@ -350,8 +347,7 @@ try {
fs.writeFileSync(path.join(docsPath, 'archive.html'), minifiedArchivedOutput);
console.log(`${chalk.green('SUCCESS!')} archive.html file generated!`);
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During archive.html generation: ${err}`);
process.exit(1);
}
@ -384,8 +380,7 @@ try {
const minifiedGlossaryOutput = minifyHTML(glossaryOutput);
fs.writeFileSync(path.join(docsPath, 'glossary.html'), minifiedGlossaryOutput);
console.log(`${chalk.green('SUCCESS!')} glossary.html file generated!`);
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During glossary.html generation: ${err}`);
process.exit(1);
}
@ -396,12 +391,10 @@ staticFiles.forEach(f => {
if(f !== 'array.html') {
let fileData = fs.readFileSync(path.join(staticPartsPath, f), 'utf8');
fs.writeFileSync(path.join(docsPath, f), generateMenuForStaticPage(fileData));
}
else
} else
fs.copyFileSync(path.join(staticPartsPath, f), path.join(docsPath, f));
console.log(`${chalk.green('SUCCESS!')} ${f} file copied!`);
}
catch (err) {
} catch (err) {
console.log(`${chalk.red('ERROR!')} During ${f} copying: ${err}`);
process.exit(1);
}