\begin{quote}
Find a file or directory by walking up parent directories \end{quote}
\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md270}{}\doxysection{Install}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md270}

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

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

\begin{DoxyCode}{0}
\DoxyCodeLine{/}
\DoxyCodeLine{└── Users}
\DoxyCodeLine{    └── sindresorhus}
\DoxyCodeLine{        ├── unicorn.png}
\DoxyCodeLine{        └── foo}
\DoxyCodeLine{            └── bar}
\DoxyCodeLine{                ├── baz}
\DoxyCodeLine{                └── example.js }

\end{DoxyCode}


{\ttfamily example.\+js}


\begin{DoxyCode}{0}
\DoxyCodeLine{const path = require('path');}
\DoxyCodeLine{const findUp = require('find-\/up');}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    console.log(await findUp('unicorn.png'));}
\DoxyCodeLine{    //=> '/Users/sindresorhus/unicorn.png'}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log(await findUp(['rainbow.png', 'unicorn.png']));}
\DoxyCodeLine{    //=> '/Users/sindresorhus/unicorn.png'}
\DoxyCodeLine{}
\DoxyCodeLine{    console.log(await findUp(async directory => \{}
\DoxyCodeLine{        const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));}
\DoxyCodeLine{        return hasUnicorns \&\& directory;}
\DoxyCodeLine{    \}, \{type: 'directory'\}));}
\DoxyCodeLine{    //=> '/Users/sindresorhus'}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md272}{}\doxysection{API}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md272}
\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md273}{}\doxysubsection{find\+Up(name, options?)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md273}
\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md274}{}\doxysubsection{find\+Up(matcher, options?)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md274}
Returns a {\ttfamily Promise} for either the path or {\ttfamily undefined} if it couldn\textquotesingle{}t be found.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md275}{}\doxysubsection{find\+Up(\mbox{[}...\+name\mbox{]}, options?)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md275}
Returns a {\ttfamily Promise} for either the first path found (by respecting the order of the array) or {\ttfamily undefined} if none could be found.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md276}{}\doxysubsection{find\+Up.\+sync(name, options?)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md276}
\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md277}{}\doxysubsection{find\+Up.\+sync(matcher, options?)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md277}
Returns a path or {\ttfamily undefined} if it couldn\textquotesingle{}t be found.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md278}{}\doxysubsection{find\+Up.\+sync(\mbox{[}...\+name\mbox{]}, options?)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md278}
Returns the first path found (by respecting the order of the array) or {\ttfamily undefined} if none could be found.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md279}{}\doxysubsubsection{name}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md279}
Type\+: {\ttfamily string}

Name of the file or directory to find.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md280}{}\doxysubsubsection{matcher}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md280}
Type\+: {\ttfamily Function}

A function that will be called with each directory until it returns a {\ttfamily string} with the path, which stops the search, or the root directory has been reached and nothing was found. Useful if you want to match files with certain patterns, set of permissions, or other advanced use-\/cases.

When using async mode, the {\ttfamily matcher} may optionally be an async or promise-\/returning function that returns the path.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md281}{}\doxysubsubsection{options}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md281}
Type\+: {\ttfamily object}\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md282}{}\doxyparagraph{cwd}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md282}
Type\+: {\ttfamily string}~\newline
 Default\+: {\ttfamily process.\+cwd()}

Directory to start from.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md283}{}\doxyparagraph{type}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md283}
Type\+: {\ttfamily string}~\newline
 Default\+: `\textquotesingle{}file'{\ttfamily $<$br$>$ Values\+:}\textquotesingle{}file\textquotesingle{}\textquotesingle{}directory\textquotesingle{}\`{}

The type of paths that can match.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md284}{}\doxyparagraph{allow\+Symlinks}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md284}
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__angular_compiler_cli_node_modules_find_up_readme_autotoc_md285}{}\doxysubsection{find\+Up.\+exists(path)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md285}
Returns a {\ttfamily Promise$<$boolean$>$} of whether the path exists.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md286}{}\doxysubsection{find\+Up.\+sync.\+exists(path)}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md286}
Returns a {\ttfamily boolean} of whether the path exists.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md287}{}\doxysubsubsection{path}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md287}
Type\+: {\ttfamily string}

Path to a file or directory.\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md288}{}\doxysubsection{find\+Up.\+stop}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md288}
A \href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}{\texttt{ {\ttfamily Symbol}}} that can be returned by a {\ttfamily matcher} function to stop the search and cause {\ttfamily find\+Up} to immediately return {\ttfamily undefined}. Useful as a performance optimization in case the current working directory is deeply nested in the filesystem.


\begin{DoxyCode}{0}
\DoxyCodeLine{const path = require('path');}
\DoxyCodeLine{const findUp = require('find-\/up');}
\DoxyCodeLine{}
\DoxyCodeLine{(async () => \{}
\DoxyCodeLine{    await findUp(directory => \{}
\DoxyCodeLine{        return path.basename(directory) === 'work' ? findUp.stop : 'logo.png';}
\DoxyCodeLine{    \});}
\DoxyCodeLine{\})(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md289}{}\doxysection{Related}\label{md_sfcode_node_modules__angular_compiler_cli_node_modules_find_up_readme_autotoc_md289}

\begin{DoxyItemize}
\item \href{https://github.com/sindresorhus/find-up-cli}{\texttt{ find-\/up-\/cli}} -\/ CLI for this module
\item \href{https://github.com/sindresorhus/pkg-up}{\texttt{ pkg-\/up}} -\/ Find the closest package.\+json file
\item \href{https://github.com/sindresorhus/pkg-dir}{\texttt{ pkg-\/dir}} -\/ Find the root directory of an npm package
\item \href{https://github.com/sindresorhus/resolve-from}{\texttt{ resolve-\/from}} -\/ Resolve the path of a module like {\ttfamily require.\+resolve()} but from a given path
\end{DoxyItemize}

\DoxyHorRuler{0}


 {\bfseries{ \href{https://tidelift.com/subscription/pkg/npm-find-up?utm_source=npm-find-up&utm_medium=referral&utm_campaign=readme}{\texttt{ Get professional support for \textquotesingle{}find-\/up\textquotesingle{} with a Tidelift subscription}} }} ~\newline
 \textsubscript{ Tidelift helps make open source sustainable for maintainers while giving companies~\newline
assurances about security, maintenance, and licensing for their dependencies. }  