Installations
npm install del
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>=18
Node Version
22.6.0
NPM Version
10.6.0
Score
97.3
Supply Chain
98.9
Quality
76.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (94.88%)
TypeScript (5.12%)
Developer
sindresorhus
Download Statistics
Total Downloads
4,389,818,299
Last Day
918,547
Last Week
5,666,196
Last Month
46,290,876
Last Year
691,530,637
GitHub Statistics
1,330 Stars
125 Commits
65 Forks
20 Watching
2 Branches
24 Contributors
Sponsor this package
Package Meta Information
Latest Version
8.0.0
Package Id
del@8.0.0
Unpacked Size
12.33 kB
Size
3.97 kB
File Count
5
NPM Version
10.6.0
Node Version
22.6.0
Publised On
07 Oct 2024
Total Downloads
Cumulative downloads
Total Downloads
4,389,818,299
Last day
-17.4%
918,547
Compared to previous day
Last week
-44.2%
5,666,196
Compared to previous week
Last month
-22%
46,290,876
Compared to previous month
Last year
-3.1%
691,530,637
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
del
Delete files and directories using globs
Similar to rimraf, but with a Promise API and support for multiple files and globbing. It also protects you against deleting the current working directory and above.
Install
1npm install del
Usage
1import {deleteAsync} from 'del'; 2 3const deletedFilePaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']); 4const deletedDirectoryPaths = await deleteAsync(['temp', 'public']); 5 6console.log('Deleted files:\n', deletedFilePaths.join('\n')); 7console.log('\n\n'); 8console.log('Deleted directories:\n', deletedDirectoryPaths.join('\n'));
Beware
The glob pattern **
matches all children and the parent.
So this won't work:
1deleteSync(['public/assets/**', '!public/assets/goat.png']);
You have to explicitly ignore the parent directories too:
1deleteSync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);
To delete all subdirectories inside public/
, you can do:
1deleteSync(['public/*/']);
Suggestions on how to improve this welcome!
API
Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use path.posix.join()
instead of path.join()
.
deleteAsync(patterns, options?)
Returns Promise<string[]>
with the deleted paths.
deleteSync(patterns, options?)
Returns string[]
with the deleted paths.
patterns
Type: string | string[]
See the supported glob patterns.
options
Type: object
You can specify any of the globby
options in addition to the below options. In contrast to the globby
defaults, expandDirectories
, onlyFiles
, and followSymbolicLinks
are false
by default.
force
Type: boolean
Default: false
Allow deleting the current working directory and outside.
dryRun
Type: boolean
Default: false
See what would be deleted.
1import {deleteAsync} from 'del'; 2 3const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true}); 4 5console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
dot
Type: boolean
Default: false
Allow patterns to match files/folders that start with a period (.
).
This option is passed through to fast-glob
.
Note that an explicit dot in a portion of the pattern will always match dot files.
Example
directory/
├── .editorconfig
└── package.json
1import {deleteSync} from 'del'; 2 3deleteSync('*', {dot: false}); 4//=> ['package.json'] 5deleteSync('*', {dot: true}); 6//=> ['.editorconfig', 'package.json']
concurrency
Type: number
Default: Infinity
Minimum: 1
Concurrency limit.
onProgress
Type: (progress: ProgressData) => void
Called after each file or directory is deleted.
1import {deleteAsync} from 'del'; 2 3await deleteAsync(patterns, { 4 onProgress: progress => { 5 // … 6}});
ProgressData
1{ 2 totalCount: number, 3 deletedCount: number, 4 percent: number, 5 path?: string 6}
percent
is a value between0
and1
path
is the absolute path of the deleted file or directory. It will not be present if nothing was deleted.
CLI
See del-cli for a CLI for this module and trash-cli for a safe version that is suitable for running by hand.
Related
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
security policy file detected
Details
- Info: security policy file detected: .github/security.md:1
- Info: Found linked content: .github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/security.md:1
- Info: Found text in security policy: .github/security.md:1
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 12/30 approved changesets -- score normalized to 4
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/del/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/del/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:26
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 12 are checked with a SAST tool
Score
4.6
/10
Last Scanned on 2024-12-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to del
unset-value
Delete nested properties from an object using dot notation.
base
Framework for rapidly creating high quality, server-side node.js applications, using plugins like building blocks
del-cli
Delete files and directories - Cross-platform
micromark-extension-gfm-strikethrough
micromark extension to support GFM strikethrough