# @hyperse/delete-empty-folders

> Recursively delete all empty folders in a directory and child directories.

Latest version **1.0.1** (published 2024-06-12) · 0 weekly downloads

## Install

```sh
npm install @hyperse/delete-empty-folders
pnpm add @hyperse/delete-empty-folders
yarn add @hyperse/delete-empty-folders
bun add @hyperse/delete-empty-folders
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-06-12 |
| First published | 2024-06-12 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 2 |
| Unpacked size | 19.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | tianyingchun |
| Keywords | hyperse, del, delete, dir, directory, empty, files, folder, recurse, recursive, remove |

## Links

- npm: https://www.npmjs.com/package/@hyperse/delete-empty-folders
- Repository: https://github.com/hyperse-io/delete-empty-folders
- Homepage: https://github.com/hyperse-io/delete-empty-folders#readme
- Issues: https://github.com/hyperse-io/delete-empty-folders/issues
- npm.io page: https://npm.io/package/@hyperse/delete-empty-folders

## Dependencies (2)

- [rimraf](https://npm.io/package/rimraf.md) ^5.0.7
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.1

## Recent versions

- 1.0.1 (latest) — 2024-06-12

## README

# @hyperse/delete-empty-folders

<p align="left">
  <a aria-label="Build" href="https://github.com/hyperse-io/delete-empty-folders/actions?query=workflow%3ACI">
    <img alt="build" src="https://img.shields.io/github/actions/workflow/status/hyperse-io/delete-empty-folders/ci-integrity.yml?branch=main&label=ci&logo=github&style=flat-quare&labelColor=000000" />
  </a>
  <a aria-label="stable version" href="https://www.npmjs.com/package/@hyperse/delete-empty-folders">
    <img alt="stable version" src="https://img.shields.io/npm/v/%40hyperse%2Fdelete-empty-folders?branch=main&label=version&logo=npm&style=flat-quare&labelColor=000000" />
  </a>
  <a aria-label="Top language" href="https://github.com/hyperse-io/delete-empty-folders/search?l=typescript">
    <img alt="GitHub top language" src="https://img.shields.io/github/languages/top/hyperse-io/delete-empty-folders?style=flat-square&labelColor=000&color=blue">
  </a>
  <a aria-label="Licence" href="https://github.com/hyperse-io/delete-empty-folders/blob/main/LICENSE">
    <img alt="Licence" src="https://img.shields.io/github/license/hyperse-io/ts-node-paths?style=flat-quare&labelColor=000000" />
  </a>
</p>

> Recursively delete all empty folders in a directory and child directories.

Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

- [Install](#install)
- [Usage](#usage)
- [API](#api)
  - [async-await (promise)](#async-await-promise)
  - [async callback](#async-callback)
  - [sync](#sync)
- [examples](#examples)

_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save @hyperse/delete-empty-folders
```

## Usage

```ts
import { deleteEmpty, deleteEmptySync } from '@hyperse/delete-empty-folders';
```

## API

Given the following directory structure, the **highlighted directories** would be deleted.

```diff
foo/
└─┬ a/
- ├── aa/
  ├── bb/
  │ └─┬ bbb/
  │ │ ├── one.txt
  │ │ └── two.txt
- ├── cc/
- ├ b/
- └ c/
```

### async-await (promise)

If no callback is passed, a promise is returned. Returns the array of deleted directories.

```ts
(async () => {
  let deleted = await deleteEmpty('foo');
  console.log(deleted); //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
})();

// or
deleteEmpty('foo/')
  .then((deleted) => console.log(deleted)) //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
  .catch(console.error);
```

### sync

Returns the array of deleted directories.

```js
console.log(deleteEmptySync('foo/')); //=> ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']
```

---
_Source: https://npm.io/package/@hyperse/delete-empty-folders · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
