Package Exports
- make-empty-dir
- make-empty-dir/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (make-empty-dir) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
make-empty-dir
Ensures that a directory is empty
Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted.
It works faster than emptyDir()
of fs-extra
because the contents of the directory are not read before the creation of the directory.
Installation
<npm|yarn|pnpm> add make-empty-dir
Usage
'use strict'
const makeEmptyDir = require('make-empty-dir')
await makeEmptyDir('dir-name')
// or create the parent dir as well
await makeEmptyDir('dir/subdir', { recursive: true })
API
makeEmptyDir(dir: string, [opts]): Promise<'created' | 'emptied'>
Arguments:
dir
- Path - the path of the directory.opts.recursive
- Boolean - Optional. If true, parent directories will be created.
Returns:
A string is returned.
'created'
- if there was no directory'emptied'
- if there was a directory and the its contents were removed.