UNPKG

create-readme

Version:

Automatically creates README.md based on package.json and other existing files.

54 lines (48 loc) 1.75 kB
// Generated by CoffeeScript 2.3.2 (function() { var OptionsParser, logger, hasProp = {}.hasOwnProperty; logger = require('./logger'); // Sets options based on command line arguments, pkg.config.readme, and defaults module.exports = OptionsParser = class OptionsParser { // Create a new OptionsSetter constructor() { void 0; } // Set options based on a parameter, pkg.config.readme, and defaults // @param pkg [Object] The content of a package.json // @param (options) [Object] An object with options to overwrite defaults // @returns [Object] The options parse(pkg, options) { var key, ref, ref1, val; logger.info("Parsing options"); if (options == null) { options = {}; } if (((ref = pkg.config) != null ? ref.readme : void 0) != null) { logger.silly("------------------------------------------------"); logger.silly("Options read from package.json config"); ref1 = pkg.config.readme; for (key in ref1) { if (!hasProp.call(ref1, key)) continue; val = ref1[key]; if (!(options[key] == null)) { continue; } logger.silly(key + ": " + val); options[key] = val; } logger.silly("------------------------------------------------"); } options.git = pkg.git; if (options.filename == null) { options.filename = './README.md'; } logger.silly("------------------------------------------------"); logger.silly("General options:"); logger.silly(JSON.stringify(options, null, 2)); logger.silly("------------------------------------------------"); return options; } }; }).call(this);