\begin{quote}
Finds the common standard cache directory \end{quote}
The \href{https://github.com/istanbuljs/nyc}{\texttt{ {\ttfamily nyc}}} and \href{https://ava.li}{\texttt{ {\ttfamily AVA}}} projects decided to standardize on a common directory structure for storing cache information\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\# nyc}
\DoxyCodeLine{./node\_modules/.cache/nyc}
\DoxyCodeLine{}
\DoxyCodeLine{\# ava}
\DoxyCodeLine{./node\_modules/.cache/ava}
\DoxyCodeLine{}
\DoxyCodeLine{\# your-\/module}
\DoxyCodeLine{./node\_modules/.cache/your-\/module }

\end{DoxyCode}


This module makes it easy to correctly locate the cache directory according to this shared spec. If this pattern becomes ubiquitous, clearing the cache for multiple dependencies becomes easy and consistent\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{rm -\/rf ./node\_modules/.cache }

\end{DoxyCode}


If you decide to adopt this pattern, please file a PR adding your name to the list of adopters below.\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32460}{}\doxysection{Install}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32460}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install find-\/cache-\/dir }

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

\begin{DoxyCode}{0}
\DoxyCodeLine{const findCacheDir = require('find-\/cache-\/dir');}
\DoxyCodeLine{}
\DoxyCodeLine{findCacheDir(\{name: 'unicorns'\});}
\DoxyCodeLine{//=> '/user/path/node-\/modules/.cache/unicorns' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32462}{}\doxysection{API}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32462}
\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32463}{}\doxysubsection{find\+Cache\+Dir(\mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32463}
Finds the cache directory using the supplied options. The algorithm tries to find a {\ttfamily package.\+json} file, searching every parent directory of the {\ttfamily cwd} specified (or implied from other options). It returns a {\ttfamily string} containing the absolute path to the cache directory, or {\ttfamily null} if {\ttfamily package.\+json} was never found.\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32464}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32464}
Type\+: {\ttfamily Object}\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32465}{}\doxyparagraph{name}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32465}
{\itshape Required}~\newline
 Type\+: {\ttfamily string}

Should be the same as your project name in {\ttfamily package.\+json}.\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32466}{}\doxyparagraph{files}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32466}
Type\+: {\ttfamily string\mbox{[}\mbox{]}} {\ttfamily string}

An array of files that will be searched for a common parent directory. This common parent directory will be used in lieu of the {\ttfamily cwd} option below.\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32467}{}\doxyparagraph{cwd}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32467}
Type\+: {\ttfamily string}~\newline
 Default {\ttfamily process.\+cwd()}

Directory to start searching for a {\ttfamily package.\+json} from.\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32468}{}\doxyparagraph{create}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32468}
Type\+: {\ttfamily boolean}~\newline
 Default {\ttfamily false}

If {\ttfamily true}, the directory will be created synchronously before returning.\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32469}{}\doxyparagraph{thunk}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32469}
Type\+: {\ttfamily boolean}~\newline
 Default {\ttfamily false}

If {\ttfamily true}, this modifies the return type to be a function that is a thunk for {\ttfamily path.\+join(the\+Found\+Cache\+Directory)}.


\begin{DoxyCode}{0}
\DoxyCodeLine{const thunk = findCacheDir(\{name: 'foo', thunk: true\});}
\DoxyCodeLine{}
\DoxyCodeLine{thunk();}
\DoxyCodeLine{//=> '/some/path/node\_modules/.cache/foo'}
\DoxyCodeLine{}
\DoxyCodeLine{thunk('bar.js')}
\DoxyCodeLine{//=> '/some/path/node\_modules/.cache/foo/bar.js'}
\DoxyCodeLine{}
\DoxyCodeLine{thunk('baz', 'quz.js')}
\DoxyCodeLine{//=> '/some/path/node\_modules/.cache/foo/baz/quz.js' }

\end{DoxyCode}


This is helpful for actually putting actual files in the cache!\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32470}{}\doxysection{Adopters}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32470}

\begin{DoxyItemize}
\item \href{https://ava.li}{\texttt{ {\ttfamily AVA}}}
\item \href{https://github.com/istanbuljs/nyc}{\texttt{ {\ttfamily nyc}}}
\item \href{https://github.com/babel/babel-loader}{\texttt{ {\ttfamily babel-\/loader}}}
\item \href{https://github.com/MoOx/eslint-loader}{\texttt{ {\ttfamily eslint-\/loader}}}
\item \href{https://phenomic.io}{\texttt{ {\ttfamily Phenomic}}}
\item \href{https://github.com/Beg-in/javascripthon-loader}{\texttt{ {\ttfamily javascripthon-\/loader}}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32471}{}\doxysection{License}\label{md_sfcode_node_modules_webpack_node_modules_find_cache_dir_readme_autotoc_md32471}
MIT 