{"id":13941814,"url":"https://github.com/gulpjs/empty-dir","last_synced_at":"2025-10-19T11:31:23.846Z","repository":{"id":16834234,"uuid":"19593712","full_name":"gulpjs/empty-dir","owner":"gulpjs","description":"Check if a directory is empty.","archived":false,"fork":false,"pushed_at":"2023-12-29T20:12:12.000Z","size":26,"stargazers_count":20,"open_issues_count":0,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-10-29T15:14:42.331Z","etag":null,"topics":["check","directory","empty","folder","is-empty","javascript"],"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/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":["gulpjs","phated","yocontra"],"tidelift":"npm/gulp","open_collective":"gulpjs"}},"created_at":"2014-05-09T00:34:26.000Z","updated_at":"2023-11-05T01:11:41.000Z","dependencies_parsed_at":"2023-12-22T14:05:17.747Z","dependency_job_id":"7c71ca46-97c2-4921-839d-7869545b46a7","html_url":"https://github.com/gulpjs/empty-dir","commit_stats":{"total_commits":23,"total_committers":9,"mean_commits":"2.5555555555555554","dds":0.7391304347826086,"last_synced_commit":"46a098a9cae18a52d7db384723e6ef1439959a86"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fempty-dir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fempty-dir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fempty-dir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Fempty-dir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/empty-dir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116959,"owners_count":19258333,"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":["check","directory","empty","folder","is-empty","javascript"],"created_at":"2024-08-08T02:01:29.937Z","updated_at":"2025-10-19T11:31:18.578Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://gulpjs.com\"\u003e\n    \u003cimg height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# empty-dir\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nCheck if a directory is empty.\n\n## Usage\n\n```js\nvar emptyDir = require('empty-dir');\n\n// Using an error-back\nemptyDir('./', function (err, result) {\n  if (err) {\n    console.error(err);\n  } else {\n    console.log('Directory is empty:', result);\n  }\n});\n\n// Using a Promise\nemptyDir('./').then(function (result) {\n  console.log('Directory is empty:', result);\n});\n\nvar result = emptyDir.sync('./test/empty');\nconsole.log('Directory is empty:', result);\n```\n\n## API\n\n### `emptyDir(paths, [filterFunction], [callback])`\n\nTakes a path string or array of path strings and returns a Promise. Checks if the given paths are empty and resolves with a boolean indicating if the paths are empty directories. Optionally takes a filter function to filter out files that cause false positives. Also, can take a node-style callback function instead of returning a Promise.\n\n### `emptyDir.sync(paths, [filterFunction])`\n\nSame as the above API but operates and returns synchronously. An error will be thrown.\n\n#### Filter function\n\nBoth async and sync take a filter function as the second argument, to ignore files like `.DS_Store` on mac or `Thumbs.db` on windows from causing false-negatives.\n\n```js\nvar emptyDir = require('empty-dir');\n\nfunction filter(filepath) {\n  return /(Thumbs\\.db|\\.DS_Store)$/i.test(filepath);\n}\n\nemptyDir('./', filter, function (err, isEmpty) {\n  if (err) {\n    console.error(err);\n  } else {\n    console.log('Directory is empty:', isEmpty);\n  }\n});\n\nvar isEmpty = emptyDir.sync('./test/empty', filter);\nconsole.log('Directory is empty:', isEmpty);\n```\n\n#### Promises\n\nGlobal promises are required for this module. If you are using a platform that doesn't have promise support, you'll need to polyfill Promise on the global.\n\n```js\nglobal.Promise = require('insert-your-promise-polyfill-here');\n\nvar emptyDir = require('empty-dir');\n\nemptyDir('./').then(function (result) {\n  console.log('Directory is empty:', result);\n});\n```\n\n## License\n\nMIT\n\n\u003c!-- prettier-ignore-start --\u003e\n[downloads-image]: https://img.shields.io/npm/dm/empty-dir.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/empty-dir\n[npm-image]: https://img.shields.io/npm/v/empty-dir.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/empty-dir/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/empty-dir/dev.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/empty-dir\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/empty-dir/master.svg?style=flat-square\n\u003c!-- prettier-ignore-end --\u003e\n","funding_links":["https://github.com/sponsors/gulpjs","https://github.com/sponsors/phated","https://github.com/sponsors/yocontra","https://tidelift.com/funding/github/npm/gulp","https://opencollective.com/gulpjs"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fempty-dir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Fempty-dir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Fempty-dir/lists"}