Created
February 12, 2019 02:55
-
-
Save stevenbeales/08ee86ddefa30ac413c776534fdb5176 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
const fs = require('fs'); | |
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined); |
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
createDirIfNotExists('test'); // creates the directory 'test', if it doesn't exist | |
Creates a directory, if it does not exist. | |
Use fs.existsSync() to check if the directory exists, fs.mkdirSync() to create it. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment