emp
Remove all the stuff inside a directory Synchronously or Asynchronously
Installation
npm install emp
Usage
const dirPath = 'path/to/folder'
const { empSync, emp } = require('emp')
emp(dirPath).then()
empSync(dirPath)
const { isEmpty, isEmptySync } = require('emp')
isEmpty(dirPath).then(result => {})
isEmptySync(dirPath)
API Documentation
A little bit setup for demonstration:
const { emp, empSync, isEmpty, isEmptySync } = require('emp')
const dirPath = 'path/to/folder'
Empty a directory
emp(path, removeDir).then()
empSync(path, removeDir)
where
- path is the location of the directory
- removeDir is a
Boolean
flag tells whether you want to remove the current directory or just to empty its content, default to false
(not to remove)
If there's nothing at the given path, nothing happens(No error will be thrown)
Check if a directory is empty
isEmpty(path).then(result => {})
isEmptySync(path)
where
- path is the location of the directory
Result is either true
or false
. If the path is not a directory, error will be thrown