Skip to content

Instantly share code, notes, and snippets.

@kubosho
Created September 19, 2015 23:58
Show Gist options
  • Select an option

  • Save kubosho/d4052651a1c8b8153a5b to your computer and use it in GitHub Desktop.

Select an option

Save kubosho/d4052651a1c8b8153a5b to your computer and use it in GitHub Desktop.
ディレクトリの有無を fs.exists() で検証して、無かったらディレクトリを作る
var fs = require("fs");
var directory = "foo";
fs.exists(directory, function(exists) {
if (!exists) {
fs.mkdir(directory, function(err) {
if (err) {
console.log(err);
return 1;
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment