Created
September 19, 2015 23:58
-
-
Save kubosho/d4052651a1c8b8153a5b to your computer and use it in GitHub Desktop.
ディレクトリの有無を fs.exists() で検証して、無かったらディレクトリを作る
This file contains hidden or 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 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