createDir

Creates a directory based on the dirPath parameter. It resolves dirPath if successful, but rejects a CreatingDirError instance if it fails.
Parameter ListReturnsRejection Errors
  • dirPath: string
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function createDir(dirPath[, tuple]): Promise<string || Array>
1 2 3 4 import {createDir} from 'puddy-m/lib/fileFunctions' createDir('path/to/dir') .then(dirPath=>console.log(dirPath)) // prints 'path/to/dir'
1 2 3 4 import {createDir} from 'puddy-m/lib/fileFunctions' createDir(true) .catch(e=>e) // rejects an ENOENT or CreatingDirError.
1 2 3 4 5 6 // Using it with tuple parameter import {createDir} from 'puddy-m/lib/fileFunctions' createDir('path/to/dir1', []) .then(tuple=>validateString('World', tuple)) .then(([dir1, str])=> first + ' - ' + str) // "path/to/dir1 - World"