Skip to content

Instantly share code, notes, and snippets.

@jasonmelgoza
Last active February 8, 2018 05:47
Show Gist options
  • Save jasonmelgoza/81a20780dd1be82caac36abacf5733fd to your computer and use it in GitHub Desktop.
Save jasonmelgoza/81a20780dd1be82caac36abacf5733fd to your computer and use it in GitHub Desktop.
Lodash readme doc script for Node.js
var _ = require('lodash')
var fs = require('fs')
var module = require('./package.json')
// Read external file
var srcCSS = fs.readFileSync('./'+module.name+'.css', 'utf8')
// Read template
var template = fs.readFileSync('./templates/README.md', 'utf8')
// Create lodash template function
var tpl = _.template(template)
// Render template function to an HTML string
var md = tpl({
module: module,
srcCSS: srcCSS
})
// Write file
fs.writeFileSync('./README.md', md)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment