Created
February 14, 2013 22:14
-
-
Save finalclass/4956903 to your computer and use it in GitHub Desktop.
Join .md (markdown) files in directory and save it to build.md file.
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
#!/usr/local/bin/node | |
var fs = require('fs'); | |
fs.readdir(__dirname, function (err, files) { | |
var contents = [], | |
mdFiles; | |
mdFiles = files.filter(function (file) { | |
return file.substr(-3) === '.md' && | |
file !== 'build.md'; | |
}); | |
mdFiles.sort(); | |
mdFiles.forEach(function (file, index) { | |
contents.push(fs.readFileSync(file, 'utf-8')); | |
}); | |
fs.writeFile(__dirname + '/build.md', contents.join('\n\n')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment