Created
November 24, 2012 15:45
-
-
Save jonvuri/4140206 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 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