create-readme
Version:
Automatically creates README.md based on package.json and other existing files.
54 lines (42 loc) • 1.56 kB
JavaScript
// Generated by CoffeeScript 2.3.2
(function() {
var Promise, TemplateLoader, fs, logger, path;
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs'));
path = require('path');
logger = require('./logger');
// Loads the template file
module.exports = TemplateLoader = (function() {
class TemplateLoader {
// Creates a new TemplateParser
// @param (options) [Object] Optional set of options
// @option options templateFile [String] The template file [__dirname + '/templates/README.md']
// @option options encoding [String] Encoding for reading the file ['utf-8']
// @returns [Promise<String>] The template string
constructor(options) {
var base, base1;
this.options = options;
if (this.options == null) {
this.options = {};
}
if ((base = this.options).templateFile == null) {
base.templateFile = path.resolve(__dirname, '../templates/README.md');
}
if ((base1 = this.options).encoding == null) {
base1.encoding = 'utf-8';
}
}
// Load template
loadTemplate() {
logger.info("Loading template");
logger.debug(" Loading template from " + this.options.templateFile);
return fs.readFileAsync(this.options.templateFile, {
encoding: this.options.encoding
});
}
};
// @property [String] The name of this component
TemplateLoader.name = "TemplateLoader";
return TemplateLoader;
}).call(this);
}).call(this);