Add util.pitch.

This commit is contained in:
John-David Dalton
2016-05-30 08:04:00 -07:00
parent 695d74d7c5
commit 77cf88a3bf
7 changed files with 98 additions and 62 deletions

View File

@@ -5,6 +5,8 @@ var _ = require('lodash'),
fs = require('fs-extra'),
path = require('path');
var util = require('../common/util');
var basePath = path.join(__dirname, '..', '..'),
docPath = path.join(basePath, 'doc'),
readmePath = path.join(docPath, 'README.md');
@@ -32,24 +34,29 @@ var config = {
}
};
function postprocess(string) {
/**
* Post-process `markdown` to make adjustments.
*
* @param {string} markdown The markdown to process.
* @returns {string} Returns the processed markdown.
*/
function postprocess(markdown) {
// Wrap symbol property identifiers in brackets.
return string.replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]');
return markdown.replace(/\.(Symbol\.(?:[a-z]+[A-Z]?)+)/g, '[$1]');
}
/*----------------------------------------------------------------------------*/
function onComplete(error) {
if (error) {
throw error;
}
}
/**
* Creates the documentation markdown formatted for 'github' or 'site'.
*
* @param {string} type The format type.
*/
function build(type) {
var options = _.defaults({}, config.base, config[type]),
markdown = docdown(options);
fs.writeFile(readmePath, postprocess(markdown), onComplete);
fs.writeFile(readmePath, postprocess(markdown), util.pitch);
}
build(_.last(process.argv));