Skip to content

Home

Create directory if not exists

Creates a directory, if it does not exist.

import { existsSync, mkdirSync } from 'fs';

const createDirIfNotExists = dir =>
  !existsSync(dir) ? mkdirSync(dir) : undefined;

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

More like this

Start typing a keyphrase to see matching snippets.