Created
March 21, 2017 02:30
-
-
Save boboidream/bfdbf2946607a1708c8f6e85737e558e 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
// Create dir recursively if it does not exist! | |
const targetDir = 'path/to/dir'; | |
targetDir.split('/').forEach((dir, index, splits) => { | |
const parent = splits.slice(0, index).join('/'); | |
const dirPath = path.resolve(parent, dir); | |
if (!fs.existsSync(dirPath)) { | |
fs.mkdirSync(dirPath); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment