Skip to content

Instantly share code, notes, and snippets.

@jonvuri
Created November 24, 2012 15:45
Show Gist options
  • Save jonvuri/4140206 to your computer and use it in GitHub Desktop.
Save jonvuri/4140206 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var path = require('path');
var mkpath = require('mkpath');
// You probably want to pass in a callback to this function to send back errors, normally
var mkfile = function (filepath) {
mkpath(path.dirname(filepath), function (err) {
if (err) {
console.log(err);
} else {
fs.writeFile(filepath, "Hey there!", function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment