create a directory, if it does not exist

PHOTO EMBED

Sat Feb 26 2022 02:23:56 GMT+0000 (Coordinated Universal Time)

Saved by @mboljar

const fs = require('fs');
const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);

// Example
createDirIfNotExists('test'); // creates the directory 'test', if it doesn't exist
content_copyCOPY

https://madza.hashnode.dev/24-modern-es6-code-snippets-to-solve-practical-js-problems?guid