Menu

gitpiper

createDirIfNotExists javascript Code Snippet in 2024

nodebeginner

Last Updated: 20 April 2024

Creates a directory, if it does not exist.

  • Use fs.existsSync() to check if the directory exists, fs.mkdirSync() to create it.
const fs = require('fs'); const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);
createDirIfNotExists('test'); // creates the directory 'test', if it doesn't exist

javascript snippet similar to createDirIfNotExists For You in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️