From 702df68b783e07d8eb6d5af63812a1cc0a603346 Mon Sep 17 00:00:00 2001 From: Michael Wuergler Date: Thu, 22 Jun 2017 15:35:14 +0100 Subject: [PATCH] more cleanup in build.js --- build.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/build.js b/build.js index a49412c..ed9bf96 100644 --- a/build.js +++ b/build.js @@ -4,9 +4,6 @@ const sortby = require('lodash.sortby'); const endpoint = 'https://www.cryptocompare.com/api/data/coinlist/'; -/** - * Build the JSON file based on the cryptocompare coinlist. - */ fetch(endpoint) .then(response => response.json()) .then(json => { @@ -14,6 +11,9 @@ fetch(endpoint) const symbols = {}; + /** + * Build the JSON file based on the cryptocompare coinlist. + */ sorted.forEach(currency => { const {Name, CoinName} = currency; symbols[Name] = CoinName; @@ -22,8 +22,9 @@ fetch(endpoint) fs.writeFileSync('cryptocurrencies.json', JSON.stringify(symbols, null, 2)); console.log('JSON File written'); - // --------------------------------------------- // - // Now build the Readme + /** + * Build the Markdown Table of currencies in the Readme. + */ const template = fs.readFileSync('readme.md').toString(); const data = JSON.parse(fs.readFileSync('cryptocurrencies.json').toString()); @@ -40,8 +41,9 @@ fetch(endpoint) table += `\n* Last updated: ${new Date().toUTCString()}`; - const target = /(\w|\W)*/gim; - const updated = template.replace(target, `\n${table}\n`); + // Look for the HTML comments in the README as a target + const targetRegex = /(\w|\W)*/gim; + const updated = template.replace(targetRegex, `\n${table}\n`); fs.writeFileSync('readme.md', updated); console.log('Readme Markdown Table updated'); })