From 9bc851965648ae7d1e0ce3129d72d8a15b7eb508 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 2 Jul 2016 09:25:45 -0700 Subject: [PATCH] Cleanup build-site script. --- lib/main/build-site.js | 51 +++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/lib/main/build-site.js b/lib/main/build-site.js index 1beacfc43..c4cf8ae8a 100644 --- a/lib/main/build-site.js +++ b/lib/main/build-site.js @@ -1,43 +1,34 @@ 'use strict'; -const fs = require('fs'), - marky = require('marky-markdown'), - path = require('path'), - _ = require('lodash'); +var _ = require('lodash'), + fs = require('fs'), + marky = require('marky-markdown'), + path = require('path'), + util = require('../common/util'); -const basePath = path.join(__dirname, '..', '..'), - docPath = path.join(basePath, 'doc'), - readmePath = path.join(docPath, 'README.md'); - -function onComplete(error) { - if (error) { - throw error; - } -} +var basePath = path.join(__dirname, '..', '..'), + docPath = path.join(basePath, 'doc'), + readmePath = path.join(docPath, 'README.md'); function build(type) { - let html = - marky(fs.readFileSync(readmePath, 'utf8'), { sanitize: false }); - const header = html('h1').first(); - const version = _.trim(header.find('span').first().text()); + var html = marky(fs.readFileSync(readmePath, 'utf8'), { 'sanitize': false }), + header = html('h1').first(), + version = _.trim(header.find('span').first().text()); header.remove(); - html = html.html(); - html = html.replace(//g, '>'); + html = html.html().replace(/(<)!--\s*|\s*--(>)/g, '$1$2'); html = [ - '---', - 'id: docs', - 'layout: docs', - 'title: lodash Documentation', - `version: ${version ? version : null}`, - '---', - html, - ].join('\n'); + '---', + 'id: docs', + 'layout: docs', + 'title: Lodash Documentation', + 'version: ' + (version || null), + '---', + html, + ].join('\n'); - // File output - fs.writeFile(path.join(docPath, `${version}.html`), html, onComplete); + fs.writeFile(path.join(docPath, version + '.html'), html, util.pitch); } build();