_build.js minor improvements, also writes to README.md now

This commit is contained in:
tycrek 2020-05-23 18:33:07 -06:00
parent eedf96a3d7
commit 144567d036
No known key found for this signature in database
GPG Key ID: F1B8043463D3ABEE
1 changed files with 21 additions and 23 deletions

View File

@ -9,23 +9,23 @@ const YAML = require('yaml');
// A hacky sort of "class" to contain methods for each section // A hacky sort of "class" to contain methods for each section
const BUILD_SECTION = { const BUILD_SECTION = {
// TODO: Make more of these YAML-based functions // TODO: Make more of these YAML-based functions
header: () => readFile('md/_header.md'), header: () => readFile('md/_header.md'),
index: () => readFile('md/_index.md'), index: () => readFile('md/_index.md'),
contributing: () => readFile('md/_contributing.md'), contributing: () => readFile('md/_contributing.md'),
browserExtensions: () => readFile('md/_browserExtensions.md'), browserExtensions: () => readFile('md/_browserExtensions.md'),
disclaimer: () => readFile('md/_disclaimer.md'), disclaimer: () => readFile('md/_disclaimer.md'),
webBasedProducts: () => generateCategorySection('Web-based products', readYaml()['web based products']), webBasedProducts: () => generateCategorySection('Web-based products', readYaml()['web based products']),
operatingSystems: () => generateCategorySection('Operating systems', readYaml()['operating systems']), operatingSystems: () => generateCategorySection('Operating systems', readYaml()['operating systems']),
desktopApps: () => generateCategorySection('Desktop apps', readYaml()['desktop applications']), desktopApps: () => generateCategorySection('Desktop apps', readYaml()['desktop applications']),
mobileApps: () => generateCategorySection('Mobile apps', readYaml()['desktop applications']), mobileApps: () => generateCategorySection('Mobile apps', readYaml()['desktop applications']),
hardware: () => generateCategorySection('Hardware', readYaml()['hardware']), hardware: () => generateCategorySection('Hardware', readYaml()['hardware']),
useful: () => {}, // TODO: Make these do stuff useful: () => '# Useful links, tools, and advice',
resources: () => {}, resources: () => readFile('md/_resources.md'),
books: () => {}, books: () => readFile('md/_books.md'),
blogs: () => {}, blogs: () => readFile('md/_blogs.md'),
news: () => {}, news: () => readFile('md/_news.md'),
lighterSide: () => {}, lighterSide: () => readFile('md/_lighterSide.md'),
closingRemarks: () => {} closingRemarks: () => readFile('md/_closingRemarks.md')
} }
/** /**
@ -55,9 +55,9 @@ function __main__() {
dgSectionData.push(BUILD_SECTION.closingRemarks()); dgSectionData.push(BUILD_SECTION.closingRemarks());
// Write to the README file // Write to the README file
fs.writeFileSync(path.join(__dirname, 'README-test.md'), dgSectionData.join(os.EOL + os.EOL)); fs.writeFileSync(path.join(__dirname, 'README.md'), dgSectionData.join(os.EOL + os.EOL));
console.log(os.EOL + 'Done!') console.log('Done!')
} }
/** /**
@ -94,7 +94,7 @@ function generateCategorySection(header, data) {
/** /**
* Generates a service (such as Gmail) section to be placed under a category section * Generates a service (such as Gmail) section to be placed under a category section
* @param {Array} data * @param {Array} data
*/ */
function generateServiceSection(data) { function generateServiceSection(data) {
// Start the section with an <h4> header and the start of a Markdown table // Start the section with an <h4> header and the start of a Markdown table
@ -112,7 +112,7 @@ function generateServiceSection(data) {
// Build the row // Build the row
let tableItem = `| ${name} | ${eyes} | ${text} |`; let tableItem = `| ${name} | ${eyes} | ${text} |`;
// Add the row to the table // Add the row to the table
serviceSection = serviceSection.concat(tableItem + os.EOL) serviceSection = serviceSection.concat(tableItem + os.EOL)
}); });
@ -120,6 +120,4 @@ function generateServiceSection(data) {
return serviceSection; return serviceSection;
} }
false __main__();
? console.log(YAML.parse(fs.readFileSync(path.join(__dirname, 'degoogle.yml')).toString())['web based products'].search_images)
: __main__();