Skip to content

Instantly share code, notes, and snippets.

@rtorr
Created November 15, 2013 00:15
Show Gist options
  • Save rtorr/7476848 to your computer and use it in GitHub Desktop.
Save rtorr/7476848 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var mkdirp = require('mkdirp');
exports.writer = function(req, body){
if (req.originalUrl !== '/'){
var destination = './dist'+req.originalUrl+'/index.html';
}else {
var destination = './dist'+req.originalUrl+'index.html';
}
var writeHtml = function(){
fs.writeFile(destination, body, function(err){
if (err){
return console.log(err);
}else {
console.log('Wrote to >' + destination);
}
});
};
mkdirp('./dist'+req.originalUrl, function(err) {
if (err){
console.log(err);
}else {
writeHtml();
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment