Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 17:24
Show Gist options
  • Select an option

  • Save anonymous/4485810 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/4485810 to your computer and use it in GitHub Desktop.
Rubbish wee grunt file to watch a set of files and spawn multimarkdown for any that change. Requires nodejs, grunt and multimarkdown installed and in the path env.
/*global module:false process:false*/
var path = require('path');
var child_process = require('child_process');
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
watch: {
'markdown': {
files: ['*.md', '../Dropbox/Blogging/*.md', '../Dropbox/Workbook Blog posts/*.md'],
tasks: 'markdown'
}
},
markdown: {
all: {
files: ['*.md', '../Dropbox/Blogging/*.md', '../Dropbox/Workbook Blog posts/*.md']
}
}
});
grunt.registerMultiTask('markdown', 'A sample task that logs stuff.', function () {
var files = grunt.file.expandFiles(this.data.files);
for(var i = files.length - 1; i >= 0; i--) {
var file = files[i];
var output = file.replace(/\.(txt|md)/, '\.html', 'i');
console.log(output);
grunt.utils.spawn({
cmd: 'multimarkdown',
args: [file, '-o', output]
}, function () {});
}
});
grunt.registerTask('default', 'watch');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment