{"id":29905415,"url":"https://github.com/ghiscoding/remove-glob","last_synced_at":"2026-06-02T01:01:26.219Z","repository":{"id":302547924,"uuid":"1012288702","full_name":"ghiscoding/remove-glob","owner":"ghiscoding","description":"a small JS and CLI cross-platform util to remove files, directories","archived":false,"fork":false,"pushed_at":"2026-05-27T04:57:10.000Z","size":450,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-27T06:25:29.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghiscoding.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"ghiscoding","patreon":null,"open_collective":null,"ko_fi":"ghiscoding","tidelift":null,"custom":null}},"created_at":"2025-07-02T05:39:09.000Z","updated_at":"2026-05-27T04:57:14.000Z","dependencies_parsed_at":"2025-08-27T00:35:36.199Z","dependency_job_id":"b1f0664a-a67b-4ea9-9e85-dd2d73020f1d","html_url":"https://github.com/ghiscoding/remove-glob","commit_stats":null,"previous_names":["ghiscoding/remove-glob"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/ghiscoding/remove-glob","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghiscoding%2Fremove-glob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghiscoding%2Fremove-glob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghiscoding%2Fremove-glob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghiscoding%2Fremove-glob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghiscoding","download_url":"https://codeload.github.com/ghiscoding/remove-glob/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghiscoding%2Fremove-glob/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33800676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-01T19:13:47.171Z","updated_at":"2026-06-02T01:01:26.209Z","avatar_url":"https://github.com/ghiscoding.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ghiscoding","https://ko-fi.com/ghiscoding"],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)\n[![Vitest](https://img.shields.io/badge/tested%20with-vitest-fcc72b.svg?logo=vitest)](https://vitest.dev/)\n[![codecov](https://codecov.io/gh/ghiscoding/remove-glob/branch/main/graph/badge.svg)](https://codecov.io/gh/ghiscoding/remove-glob)\n\u003ca href=\"https://nodejs.org/en/about/previous-releases\"\u003e\u003cimg src=\"https://img.shields.io/node/v/remove-glob.svg\" alt=\"Node\" /\u003e\u003c/a\u003e\n\n[![npm](https://img.shields.io/npm/dy/remove-glob)](https://www.npmjs.com/package/remove-glob)\n[![npm](https://img.shields.io/npm/v/remove-glob.svg)](https://www.npmjs.com/package/remove-glob)\n[![npm bundle size](https://img.shields.io/badge/API%20only%20(gzip)-1.05kB-1183c4)](https://bundlejs.com/?q=remove-glob)\n[![npm bundle size](https://img.shields.io/badge/API+CLI%20(gzip)-4.08kB-1183c4)](https://bundlejs.com/?q=remove-glob%2Cremove-glob%2Fdist%2Fcli.js)\n\n## Remove-Glob\n\nA tiny cross-platform utility to remove items or directories recursively, it also accepts an optional glob pattern. There's also a CLI for easy, cross-platform usage using [cli-nano](https://www.npmjs.com/package/cli-nano) which is the only external dependency.\n\nInspired by [rimraf](https://www.npmjs.com/package/rimraf) and [premove](https://www.npmjs.com/package/premove) but also supports glob pattern to remove multiple files or directories.\n\n### Major Changes\n#### version 0.x\n- works with Node.JS 20.x by using `tinyglobby` for glob matching\n\n#### version 1.0\n- drop `tinyglobby` and use `fs.glob` native code (requires Node.JS \u003e=22.17)\n\n--- \n\n### Install\n```sh\nnpm install remove-glob\n```\n\n### Command Line\n\nA `remove` binary is available, it takes an optional path argument (zero or multiple file/directory paths) to be removed **or** a `--glob` pattern instead of path(s).\n\n\u003e [!NOTE]\n\u003e The `paths` and `glob` arguments are both optionals, but you **must** provide at least 1 of them.\n\u003e However, please note that providing both of them simultaneously is not supported and will throw an error (choose the option that is best suited to your use case).\n\nWhen using the `--glob` option, dotfiles and dot-directories (e.g. `.env`, `.gitignore`, `.config/`) are included by default. If you want to exclude them, you can adjust your glob pattern (e.g. use `**/[!.]*.js` or add an `!**/.*` pattern).\n\n```\nUsage:\n  remove [paths..] [options] → Remove all items recursively\n\nArguments:\n  paths           Directory or file paths to remove                                           [string..]\n\nOptions:\n      --cwd       Directory to resolve from (default \".\")                                     [string]\n  -d, --dry-run   Show which files/dirs would be deleted but without actually removing them   [boolean]\n  -g, --glob      Glob pattern(s) to find which files/dirs to remove                          [array]\n  -a, --all       Include dotfiles (files starting with a dot) when matching glob patterns    [boolean]\n  -s, --stat      Show the stats of the items being removed                                   [boolean]\n  -V, --verbose   If true, it will log each file or directory being removed                   [boolean]\n  -e, --exclude   Glob pattern(s) to exclude from deletion (overrides the default patterns)   [array]\n  -h, --help      Show help                                                                   [boolean]\n  -v, --version   Show version number                                                         [boolean]\n```\n\nWhen `exclude` glob pattern(s) are provided, it will override the default exclude [`\"**/.git/**\", \"**/.git\", \"**/node_modules/**\", \"**/node_modules\"`].\n\nThe `--all`/`-a` option includes dotfiles (files starting with a dot) in glob matches. By default, dotfiles are excluded unless explicitly matched or this option is used.\n\n#### Negation Patterns\nYou can use negation patterns (starting with `!`) in glob arrays to exclude files from removal:\n\n```sh\n$ npx remove --glob \"src/**/*.js\" --glob \"!src/**/*.test.js\"\n# This will remove all .js files except those ending with .test.js\n```\n\n#### Brace Expansion\nBrace expansion is supported in glob patterns:\n\n```sh\n$ npx remove --glob \"src/*.{js,ts}\"\n# This will match both .js and .ts files in src/\n```\n\nRemove files or directories.  Note: on Windows globs must be **double quoted**, everybody else can quote however they please.\n\n```sh\n# remove \"foo\" and \"bar\" via `npx`\n$ npx remove foo bar\n\n# or remove using glob pattern(s)\n$ npx remove --glob \\\"dist/**/*.js\\\"\n$ npx remove --glob=\\\"dist/**/*.js\\\" --glob=\\\"packages/*/tsconfig.tsbuildinfo\\\"\n\n# install globally, use whenever\n$ npm install remove-glob -g\n$ remove foo bar\n$ remove --glob \\\"dist/**/*.{js,map}\\\"\n```\n\nWhen using the `--glob` option, it will skip `.git/` and `node_modules/` directories by default (internally it just set that as the default `exclude`). If you want to allow deletion of these directories, you can override the default by providing your own `--exclude` option (including an empty array to disable exclusion), for example:\n\n```sh\n# Remove everything, including .git and node_modules\n$ npx remove --glob \"**/*\" --exclude \"\"\n\n# Or exclude only .git, but allow node_modules to be deleted\n$ npx remove --glob \"**/*\" --exclude \"**/.git/**\" --exclude \"**/.git\"\n```\n\n### Usage\n\n```ts\nimport { resolve } from 'node:path';\nimport { removeSync } from 'remove-glob';\n\n// remove via paths\nremoveSync({ paths: './foobar' });\nremoveSync({ paths: ['./foo/file1.txt', './foo/file2.txt'] });\n\n// or remove via glob pattern\nremoveSync({ glob: 'foo/**/*.txt' });\n\n// Using `cwd` option\nconst dir = resolve('./foo/bar');\nawait removeSync({ paths: ['hello.txt'], cwd: dir });\n```\n\n## JavaScript API\n\n```js\nimport { removeSync } from 'remove-glob';\n\nremoveSync(opt, callback);\n```\n\nThe first argument is an object holding any of the options shown below. The last argument is an optional callback function that will be executed after all files were removed.\n\n```js\n{\n  cwd: string;                 // directory to resolve your `filepath` from, defaults to `process.cwd()`\n  dryRun: boolean;             // show what would be removed, without actually removing anything\n  paths: string | string[];    // filepath(s) to remove – may be a file or a directory.\n  glob: string | string[];     // glob pattern(s) to find which files/directories to remove\n  exclude: string | string[];  // glob pattern(s) to exclude from deletion\n  all: boolean;                // include dotfiles (files starting with a dot) in glob matches\n  stat: boolean;               // show some statistics after execution (time + file count)\n  verbose: boolean;            // print more information to console when executing the removal\n}\n```\n\n\n\u003e [!NOTE]\n\u003e The first argument is required and it **must** include either a `paths` or a `glob`, but it cannot include both options simultaneously. A\n\nWhen an `exclude` glob pattern is provided, it will override the default exclusion [`\"**/.git/**\", \"**/.git\", \"**/node_modules/**\", \"**/node_modules\"`].\n\n#### Advanced glob usage\n\n- **Negation**: Use `!pattern` in a glob array to exclude files from removal.\n- **Brace expansion**: Use `{a,b}` to match multiple alternatives in a single pattern.\n- **Dotfiles**: Use `--all`/`-a` to include dotfiles in glob matches.\n\n### Used by\n\nI use it in most of my own open source projects as a Dev Dependency (feel free to modify this list and add your project(s) as well)\n\n- [Lerna-Lite](https://github.com/lerna-lite/lerna-lite)\n- [SlickGrid](https://github.com/6pac/SlickGrid)\n- [Slickgrid-Universal](https://github.com/ghiscoding/slickgrid-universal)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghiscoding%2Fremove-glob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghiscoding%2Fremove-glob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghiscoding%2Fremove-glob/lists"}