Created
March 8, 2013 17:21
-
-
Save joyrexus/5118141 to your computer and use it in GitHub Desktop.
index2README task for simple litcoffee modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{spawn} = require 'child_process' | |
fs = require 'fs' | |
task "build", "watch and build the source", -> | |
compiler = spawn 'coffee', ['-cw', '.'] | |
compiler.stdout.on 'data', (data) -> console.log data.toString().trim() | |
compiler.stderr.on 'data', (data) -> console.error data.toString().trim() | |
# Render your literate source as a GH-highlight-able code-fenced README (a tweak of journo's Cakefile) | |
task "readme", "render index as README", -> | |
source = fs.readFileSync('index.coffee.md').toString() | |
indented = /\n\n ([\s\S]*?)\n\n(?! )/mg | |
asFenced = (match, code) -> | |
dedented = code.replace(/^ /mg, '') | |
"\n```coffeescript\n#{dedented}\n```\n" | |
fs.writeFileSync 'README.coffee.md', source.replace(indented, asFenced) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment