\begin{quote}
Get the first path that exists on disk of multiple paths \end{quote}
\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22809}{}\doxysection{Install}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22809}

\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install locate-\/path }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22810}{}\doxysection{Usage}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22810}
Here we find the first file that exists on disk, in array order.


\begin{DoxyCode}{0}
\DoxyCodeLine{const locatePath = require('locate-\/path');}
\DoxyCodeLine{}
\DoxyCodeLine{const files = [}
\DoxyCodeLine{    'unicorn.png',}
\DoxyCodeLine{    'rainbow.png', // Only this one actually exists on disk}
\DoxyCodeLine{    'pony.png'}
\DoxyCodeLine{];}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    console(await locatePath(files));}
\DoxyCodeLine{    //=> 'rainbow'}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22811}{}\doxysection{API}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22811}
\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22812}{}\doxysubsection{locate\+Path(paths, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22812}
Returns a {\ttfamily Promise$<$string$>$} for the first path that exists or {\ttfamily undefined} if none exists.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22813}{}\doxysubsubsection{paths}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22813}
Type\+: {\ttfamily Iterable$<$string$>$}

Paths to check.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22814}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22814}
Type\+: {\ttfamily Object}\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22815}{}\doxyparagraph{concurrency}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22815}
Type\+: {\ttfamily number}~\newline
 Default\+: {\ttfamily Infinity}~\newline
 Minimum\+: {\ttfamily 1}

Number of concurrently pending promises.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22816}{}\doxyparagraph{preserve\+Order}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22816}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Preserve {\ttfamily paths} order when searching.

Disable this to improve performance if you don\textquotesingle{}t care about the order.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22817}{}\doxyparagraph{cwd}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22817}
Type\+: {\ttfamily string}~\newline
 Default\+: {\ttfamily process.\+cwd()}

Current working directory.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22818}{}\doxyparagraph{type}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22818}
Type\+: {\ttfamily string}~\newline
 Default\+: {\ttfamily file}~\newline
 Values\+: {\ttfamily file} {\ttfamily directory}

The type of paths that can match.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22819}{}\doxyparagraph{allow\+Symlinks}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22819}
Type\+: {\ttfamily boolean}~\newline
 Default\+: {\ttfamily true}

Allow symbolic links to match if they point to the chosen path type.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22820}{}\doxysubsection{locate\+Path.\+sync(paths, \mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22820}
Returns the first path that exists or {\ttfamily undefined} if none exists.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22821}{}\doxysubsubsection{paths}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22821}
Type\+: {\ttfamily Iterable$<$string$>$}

Paths to check.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22822}{}\doxysubsubsection{options}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22822}
Type\+: {\ttfamily Object}\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22823}{}\doxyparagraph{cwd}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22823}
Same as above.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22824}{}\doxyparagraph{type}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22824}
Same as above.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22825}{}\doxyparagraph{allow\+Symlinks}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22825}
Same as above.\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22826}{}\doxysection{Related}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22826}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/path-exists}{\texttt{ path-\/exists}} -\/ Check if a path exists
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22827}{}\doxysection{License}\label{md_sfcode_node_modules_protractor_node_modules_locate_path_readme_autotoc_md22827}
MIT © \href{https://sindresorhus.com}{\texttt{ Sindre Sorhus}} 