del
Delete files and directories using glob patterns, with a safe promise-based API.
Repository Health
Technical Analysis
del is a small, focused Node.js library for deleting files and directories using glob patterns. It wraps globby for pattern matching and Node’s native fs.rm under the hood, exposing both a promise-based deleteAsync and a synchronous deleteSync API, each returning the list of paths actually removed.
Unlike a bare rm -rf or rimraf call, del builds in safety checks by default: it refuses to delete the current working directory or anything outside it unless you explicitly pass force: true. It also supports a dryRun mode for previewing what would be deleted, a per-file onProgress callback for reporting deletion progress, and a concurrency option for tuning how many deletions run in parallel.
What You Get
- deleteAsync and deleteSync functions that return the actual list of deleted paths
- Built-in safety checks that block deleting the cwd or paths outside it unless force is set
- dryRun mode to preview exactly what a pattern would delete before running it
- An onProgress callback reporting totalCount/deletedCount/percent as files are removed
- A concurrency option to control how many deletions run in parallel
Common Use Cases
- Clearing a dist/ or build/ output directory before a fresh build step
- Cleaning up temporary files created during a test run or CI job
- Removing generated cache or coverage folders as part of a clean script
- Pruning old log or temp files matched by a glob pattern on a schedule
Under The Hood
Architecture The entire package is one flat ES module (index.js) exporting deleteAsync and deleteSync, both built on two small shared helpers: normalizePatterns (Windows path handling via slash and is-glob) and safeCheck (guards against deleting the cwd or paths outside it via is-path-cwd and is-path-inside, throwing a PresentableError). There is no class hierarchy or plugin system — the async path resolves patterns through globby then maps deletions concurrently with p-map, while the sync path mirrors the same logic with globbySync and fs.rmSync. Deleted paths are sorted for deterministic output. It’s a deliberately thin, single-responsibility module rather than a layered system, so there’s little architectural surface to break.
Tech Stack Targets Node.js >=18 and ships as pure ESM (“type”: “module”) with a dual types/default export map and sideEffects:false for tree-shaking. Runtime dependencies are all small sindresorhus utilities: globby (pattern matching), is-glob, is-path-cwd, is-path-inside, p-map (concurrency-limited mapping), slash (path normalization), and presentable-error for user-facing error messages. Dev tooling is xo (a strict opinionated ESLint config) for linting, ava for tests, tsd for type-level testing, and tempy for isolated temp directories in tests.
Code Quality test.js contains an extensive AVA suite covering both the async and sync APIs in parallel: default behavior, dot-file matching, dry-run output, progress callbacks, absolute vs relative paths outside cwd, Windows-style backslash paths, and a dedicated regression test for an EINVAL race condition run 200 times. Type correctness is checked separately via tsd against index.test-d.ts. CI (.github/workflows/main.yml) runs the full suite across Node 18/20/22 on Ubuntu, macOS, and Windows, and the xo linter is part of the npm test script itself, so nothing merges without passing lint, tests, and type checks.
What Makes It Unique del isn’t trying to out-feature rimraf — its distinguishing choice is defaulting to safety: any attempt to delete the current working directory or a path outside it throws immediately unless the caller opts in with force: true, which prevents an entire class of “deleted my whole project” accidents that plain rm -rf/rimraf usage is prone to. Combined with dryRun and onProgress, it’s built for tooling authors who need predictable, inspectable deletion rather than raw speed.
Used by 6 apps in this directory
Airbyte
Developer Tools · Data Engineering
Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.
browserless
Developer Tools · Automation
Run headless Chrome, Firefox, and WebKit as a managed Docker service — drop-in Puppeteer and Playwright support with no infrastructure overhead.
Cocos Engine
Developer Tools · Game Development · Design Tools
Open-source, cross-platform 2D/3D game engine with Vulkan, Metal, and WebGL support for web, mobile, and instant gaming platforms
Kibana
Analytics · Monitoring
Your open source window into the Elastic Stack — query, visualize, and act on data stored in Elasticsearch with real-time dashboards, AI-assisted search, and automated alerting.
Umami
Analytics
Privacy-first web analytics that respects your users — self-hosted, cookieless, and GDPR compliant out of the box.
Webiny JS
Ecommerce · Blogging · CMS
Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.