\begin{quote}
Delete files and folders using \href{https://github.com/isaacs/minimatch\#usage}{\texttt{ globs}} \end{quote}
Similar to \href{https://github.com/isaacs/rimraf}{\texttt{ 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.

\DoxyHorRuler{0}




🐶



{\bfseries{Support this project and improve your Java\+Script skills with this great \href{https://ES6.io/friend/AWESOME}{\texttt{ ES6 course}} by Wes Bos.}}~\newline
Try his free \href{https://javascript30.com/friend/AWESOME}{\texttt{ Java\+Script 30 course}} for a taste of what to expect. You might also like his \href{https://ReactForBeginners.com/friend/AWESOME}{\texttt{ React}} and \href{https://SublimeTextBook.com/friend/AWESOME}{\texttt{ Sublime}} course.

\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8048}{}\doxysection{Install}\label{md_sfcode_node_modules_del_readme_autotoc_md8048}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install del }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8049}{}\doxysection{Usage}\label{md_sfcode_node_modules_del_readme_autotoc_md8049}

\begin{DoxyCode}{0}
\DoxyCodeLine{const del = require('del');}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    const deletedPaths = await del(['tmp/*.js', '!tmp/unicorn.js']);}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log('Deleted files and folders:\(\backslash\)n', deletedPaths.join('\(\backslash\)n'));}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8050}{}\doxysection{Beware}\label{md_sfcode_node_modules_del_readme_autotoc_md8050}
The glob pattern {\ttfamily $\ast$$\ast$} matches all children and {\itshape the parent}.

So this won\textquotesingle{}t work\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{del.sync(['public/assets/**', '!public/assets/goat.png']); }

\end{DoxyCode}


You have to explicitly ignore the parent directories too\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']); }

\end{DoxyCode}


Suggestions on how to improve this welcome!\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8051}{}\doxysection{API}\label{md_sfcode_node_modules_del_readme_autotoc_md8051}
\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8052}{}\doxysubsection{del(patterns, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_del_readme_autotoc_md8052}
Returns a promise for an array of deleted paths.\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8053}{}\doxysubsection{del.\+sync(patterns, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_del_readme_autotoc_md8053}
Returns an array of deleted paths.\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8054}{}\doxysubsubsection{patterns}\label{md_sfcode_node_modules_del_readme_autotoc_md8054}
Type\+: {\ttfamily string} {\ttfamily string\mbox{[}\mbox{]}}

See supported minimatch \href{https://github.com/isaacs/minimatch\#usage}{\texttt{ patterns}}.


\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/multimatch/blob/master/test/test.js}{\texttt{ Pattern examples with expected matches}}
\item \href{https://github.com/sindresorhus/multimatch\#globbing-patterns}{\texttt{ Quick globbing pattern overview}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8055}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_del_readme_autotoc_md8055}
Type\+: {\ttfamily Object}

See the \href{https://github.com/isaacs/node-glob\#options}{\texttt{ {\ttfamily glob} options}}.\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8056}{}\doxyparagraph{force}\label{md_sfcode_node_modules_del_readme_autotoc_md8056}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily false}

Allow deleting the current working directory and outside.\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8057}{}\doxyparagraph{dry\+Run}\label{md_sfcode_node_modules_del_readme_autotoc_md8057}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily false}

See what would be deleted.


\begin{DoxyCode}{0}
\DoxyCodeLine{const del = require('del');}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    const deletedPaths = await del(['tmp/*.js'], \{dryRun: true\});}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log('Files and folders that would be deleted:\(\backslash\)n', deletedPaths.join('\(\backslash\)n'));}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8058}{}\doxyparagraph{concurrency}\label{md_sfcode_node_modules_del_readme_autotoc_md8058}
Type\+: {\ttfamily number}~\newline
 Default\+: {\ttfamily Infinity}~\newline
 Minimum\+: {\ttfamily 1}

Concurrency limit.\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8059}{}\doxysection{CLI}\label{md_sfcode_node_modules_del_readme_autotoc_md8059}
See \href{https://github.com/sindresorhus/del-cli}{\texttt{ del-\/cli}} for a CLI for this module and \href{https://github.com/sindresorhus/trash-cli}{\texttt{ trash-\/cli}} for a safe version that is suitable for running by hand.\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8060}{}\doxysection{Related}\label{md_sfcode_node_modules_del_readme_autotoc_md8060}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/make-dir}{\texttt{ make-\/dir}} -\/ Make a directory and its parents if needed
\item \href{https://github.com/sindresorhus/globby}{\texttt{ globby}} -\/ User-\/friendly glob matching
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_del_readme_autotoc_md8061}{}\doxysection{License}\label{md_sfcode_node_modules_del_readme_autotoc_md8061}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 