del
- Version 8.0.0
- Published
- 12.6 kB
- 6 dependencies
- MIT license
Install
npm i del
yarn add del
pnpm add del
Overview
Delete files and directories
Index
Functions
Type Aliases
Functions
function deleteAsync
deleteAsync: ( patterns: string | readonly string[], options?: Options) => Promise<string[]>;
Delete files and directories using glob patterns.
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 ofpath.join()
.Parameter patterns
See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
Parameter options
You can specify any of the [
globby
options](https://github.com/sindresorhus/globby#options) in addition to thedel
options. In contrast to theglobby
defaults,expandDirectories
,onlyFiles
, andfollowSymbolicLinks
arefalse
by default.Returns
The deleted paths.
Example 1
import {deleteAsync} from 'del';const deletedPaths = await deleteAsync(['temp/*.js', '!temp/unicorn.js']);console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
function deleteSync
deleteSync: ( patterns: string | readonly string[], options?: Options) => string[];
Synchronously delete files and directories using glob patterns.
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 ofpath.join()
.Parameter patterns
See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js) - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
Parameter options
You can specify any of the [
globby
options](https://github.com/sindresorhus/globby#options) in addition to thedel
options. In contrast to theglobby
defaults,expandDirectories
,onlyFiles
, andfollowSymbolicLinks
arefalse
by default.Returns
The deleted paths.
Type Aliases
type Options
type Options = { /** Allow deleting the current working directory and outside.
@default false */ readonly force?: boolean;
/** See what would be deleted.
@default false
@example ``` import {deleteAsync} from 'del';
const deletedPaths = await deleteAsync(['temp/*.js'], {dryRun: true});
console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n')); ``` */ readonly dryRun?: boolean;
/** Concurrency limit. Minimum: `1`.
@default Infinity */ readonly concurrency?: number;
/** Called after each file or directory is deleted.
@example ``` import {deleteAsync} from 'del';
await deleteAsync(patterns, { onProgress: progress => { // … }}); ``` */ readonly onProgress?: (progress: ProgressData) => void;} & GlobbyOptions;
type ProgressData
type ProgressData = { /** Deleted files and directories count. */ readonly deletedCount: number;
/** Total files and directories count. */ readonly totalCount: number;
/** Completed percentage. A value between `0` and `1`. */ readonly percent: number;
/** The absolute path of the deleted file or directory.
It will not be present if nothing was deleted. */ readonly path?: string;};
Package Files (1)
Dependencies (6)
Dev Dependencies (5)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/del
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/del)
- HTML<a href="https://www.jsdocs.io/package/del"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3183 ms. - Missing or incorrect documentation? Open an issue for this package.