Created
November 15, 2013 00:15
-
-
Save rtorr/7476848 to your computer and use it in GitHub Desktop.
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
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