{"id":15647848,"url":"https://github.com/jonschlinkert/delete-empty","last_synced_at":"2025-04-09T13:08:13.928Z","repository":{"id":51340436,"uuid":"47315174","full_name":"jonschlinkert/delete-empty","owner":"jonschlinkert","description":"Recursively delete all empty folders in a directory and child directories.","archived":false,"fork":false,"pushed_at":"2023-03-28T15:56:20.000Z","size":63,"stargazers_count":42,"open_issues_count":5,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-09T08:58:25.330Z","etag":null,"topics":["delete","directories","directory","empty","files","glob","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-03T07:19:57.000Z","updated_at":"2024-06-18T13:55:05.197Z","dependencies_parsed_at":"2024-06-18T13:55:03.578Z","dependency_job_id":"54c336ff-176f-403b-a6d4-1d4d28e058a4","html_url":"https://github.com/jonschlinkert/delete-empty","commit_stats":{"total_commits":36,"total_committers":5,"mean_commits":7.2,"dds":"0.13888888888888884","last_synced_commit":"79cfda0161bac7f3d55d9ceac256216c17283a51"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fdelete-empty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fdelete-empty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fdelete-empty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fdelete-empty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/delete-empty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045233,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["delete","directories","directory","empty","files","glob","nodejs"],"created_at":"2024-10-03T12:21:33.663Z","updated_at":"2025-04-09T13:08:13.911Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68"],"categories":[],"sub_categories":[],"readme":"# delete-empty [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/delete-empty.svg?style=flat)](https://www.npmjs.com/package/delete-empty) [![NPM monthly downloads](https://img.shields.io/npm/dm/delete-empty.svg?style=flat)](https://npmjs.org/package/delete-empty) [![NPM total downloads](https://img.shields.io/npm/dt/delete-empty.svg?style=flat)](https://npmjs.org/package/delete-empty) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/delete-empty.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/delete-empty)\n\n\u003e Recursively delete all empty folders in a directory and child directories.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n  * [async-await (promise)](#async-await-promise)\n  * [async callback](#async-callback)\n  * [sync](#sync)\n- [CLI](#cli)\n- [About](#about)\n\n_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save delete-empty\n```\n\n## Usage\n\n```js\nconst deleteEmpty = require('delete-empty');\n```\n\n## API\n\nGiven the following directory structure, the **highlighted directories** would be deleted.\n\n```diff\nfoo/\n└─┬ a/\n- ├── aa/\n  ├── bb/\n  │ └─┬ bbb/\n  │ │ ├── one.txt\n  │ │ └── two.txt\n- ├── cc/\n- ├ b/\n- └ c/\n```\n\n### async-await (promise)\n\nIf no callback is passed, a promise is returned. Returns the array of deleted directories.\n\n```js\n(async () =\u003e {\n  let deleted = await deleteEmpty('foo');\n  console.log(deleted); //=\u003e ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']\n})();\n\n// or\ndeleteEmpty('foo/')\n  .then(deleted =\u003e console.log(deleted)) //=\u003e ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']\n  .catch(console.error);\n```\n\n### async callback\n\nReturns the array of deleted directories in the callback.\n\n```js\ndeleteEmpty('foo/', (err, deleted) =\u003e {\n  console.log(deleted); //=\u003e ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']\n});\n```\n\n### sync\n\nReturns the array of deleted directories.\n\n```js\nconsole.log(deleteEmpty.sync('foo/')); //=\u003e ['foo/aa/', 'foo/a/cc/', 'foo/b/', 'foo/c/']\n```\n\n## CLI\n\nTo use the `delete-empty` command from any directory you must first install the package globally with the following command:\n\n```sh\n$ npm install --global delete-empty\n```\n\n**Usage**\n\n```\nUsage: $ delete-empty \u003cdirectory\u003e [options]\n\nDirectory: (optional) Initial directory to begin the search for empty\n           directories. Otherwise, cwd is used.\n\n[Options]:\n  -c, --cwd           Set the current working directory for folders to search.\n  -d, --dryRun        Do a dry run without deleting any files.\n  -h, --help          Display this help menu\n  -V, --version       Display the current version of rename\n  -v, --verbose       Display all verbose logging messages (currently not used)\n\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Related projects\n\nYou might also be interested in these projects:\n\n* [copy](https://www.npmjs.com/package/copy): Copy files or directories using globs. | [homepage](https://github.com/jonschlinkert/copy \"Copy files or directories using globs.\")\n* [delete](https://www.npmjs.com/package/delete): Delete files and folders and any intermediate directories if they exist (sync and async). | [homepage](https://github.com/jonschlinkert/delete \"Delete files and folders and any intermediate directories if they exist (sync and async).\")\n* [fs-utils](https://www.npmjs.com/package/fs-utils): fs extras and utilities to extend the node.js file system module. Used in Assemble and… [more](https://github.com/assemble/fs-utils) | [homepage](https://github.com/assemble/fs-utils \"fs extras and utilities to extend the node.js file system module. Used in Assemble and many other projects.\")\n* [matched](https://www.npmjs.com/package/matched): Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and… [more](https://github.com/jonschlinkert/matched) | [homepage](https://github.com/jonschlinkert/matched \"Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules.\")\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 31 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 2  | [treble-snake](https://github.com/treble-snake) |  \n| 1  | [doowb](https://github.com/doowb) |  \n| 1  | [svenschoenung](https://github.com/svenschoenung) |  \n| 1  | [vpalmisano](https://github.com/vpalmisano) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\n### License\n\nCopyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on July 02, 2019._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fdelete-empty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fdelete-empty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fdelete-empty/lists"}