create-readme
Version:
Automatically creates README.md based on package.json and other existing files.
59 lines (48 loc) • 1.9 kB
JavaScript
// Generated by CoffeeScript 2.3.2
(function() {
var DescriptionParser, Promise, logger, os;
logger = require('../logger');
Promise = require('bluebird');
os = require('os');
// Creates a description
module.exports = DescriptionParser = (function() {
class DescriptionParser {
// Creates a new DescriptionParser that enhances the description.
// addDescription can optionally be given as an array of strings that will
// be concatenated by the module. This is to enhance readability
// of package.json
// @param (options) [Object] An optional set of options
// @option options addDescription [String] Additional text for the description ['']
constructor(options) {
var base;
this.options = options;
if (this.options == null) {
this.options = {};
}
if ((base = this.options).addDesc == null) {
base.addDesc = '';
}
if (Array.isArray(this.options.addDesc)) {
this.options.addDesc = this.options.addDesc.join('');
}
}
// Create license information by concatenating options.addDescription to
// pkg.description, separated by two line breaks.
// @param pkg [Object] package.json data
// @returns [Promise<String>] The description
run(pkg) {
logger.info("Creating description");
if (this.options.addDesc.length > 0) {
logger.debug(" Adding additional description");
return Promise.resolve(pkg.description + os.EOL + os.EOL + this.options.addDesc);
} else {
logger.debug(" Not adding additional description");
return Promise.resolve(pkg.description);
}
}
};
// @property [String] The name of this component
DescriptionParser.name = "DescriptionParser";
return DescriptionParser;
}).call(this);
}).call(this);