description and source-codefunction Mailgen(options) {
// Set options as instance members
this.theme = options.theme;
this.product = options.product;
this.themeName = (typeof this.theme === 'string' && this.theme) ? this.theme : 'default';
// No product?
if (!this.product || typeof this.product !== 'object') {
throw new Error('Please provide the `product` object.');
}
// No product name or link?
if (!this.product.name || !this.product.link) {
throw new Error('Please provide the product name and link.');
}
// Support for custom text direction (fallback to LTR)
this.textDirection = options.textDirection || 'ltr';
// Support for custom copyright (fallback to sensible default)
this.product.copyright = this.product.copyright || '© ' + new Date().getFullYear() + ' <a href="' + this.product.link + '"
target="_blank">' + this.product.name + '</a>. All rights reserved.';
// Cache theme files for later to avoid spamming fs.readFileSync()
this.cacheThemes();
}