Javascript module to extract the non-\/magic parent path from a glob string.

\href{https://nodei.co/npm/glob-parent/}{\texttt{ }} \href{https://nodei.co/npm-dl/glob-parent/}{\texttt{ }}\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32015}{}\doxysection{Usage}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32015}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install glob-\/parent -\/-\/save }

\end{DoxyCode}


{\bfseries{Examples}}


\begin{DoxyCode}{0}
\DoxyCodeLine{var globParent = require('glob-\/parent');}
\DoxyCodeLine{}
\DoxyCodeLine{globParent('path/to/*.js'); // 'path/to'}
\DoxyCodeLine{globParent('/root/path/to/*.js'); // '/root/path/to'}
\DoxyCodeLine{globParent('/*.js'); // '/'}
\DoxyCodeLine{globParent('*.js'); // '.'}
\DoxyCodeLine{globParent('**/*.js'); // '.'}
\DoxyCodeLine{globParent('path/\{to,from\}'); // 'path'}
\DoxyCodeLine{globParent('path/!(to|from)'); // 'path'}
\DoxyCodeLine{globParent('path/?(to|from)'); // 'path'}
\DoxyCodeLine{globParent('path/+(to|from)'); // 'path'}
\DoxyCodeLine{globParent('path/*(to|from)'); // 'path'}
\DoxyCodeLine{globParent('path/@(to|from)'); // 'path'}
\DoxyCodeLine{globParent('path/**/*'); // 'path'}
\DoxyCodeLine{}
\DoxyCodeLine{// if provided a non-\/glob path, returns the nearest dir}
\DoxyCodeLine{globParent('path/foo/bar.js'); // 'path/foo'}
\DoxyCodeLine{globParent('path/foo/'); // 'path/foo'}
\DoxyCodeLine{globParent('path/foo'); // 'path' (see issue \#3 for details) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32016}{}\doxysection{Escaping}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32016}
The following characters have special significance in glob patterns and must be escaped if you want them to be treated as regular path characters\+:


\begin{DoxyItemize}
\item {\ttfamily ?} (question mark)
\item {\ttfamily $\ast$} (star)
\item {\ttfamily $\vert$} (pipe)
\item {\ttfamily (} (opening parenthesis)
\item {\ttfamily )} (closing parenthesis)
\item {\ttfamily \{} (opening curly brace)
\item {\ttfamily \}} (closing curly brace)
\item {\ttfamily \mbox{[}} (opening bracket)
\item {\ttfamily \mbox{]}} (closing bracket)
\end{DoxyItemize}

{\bfseries{Example}}


\begin{DoxyCode}{0}
\DoxyCodeLine{globParent('foo/[bar]/') // 'foo'}
\DoxyCodeLine{globParent('foo/\(\backslash\)\(\backslash\)[bar]/') // 'foo/[bar]' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32017}{}\doxysection{Limitations}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32017}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32018}{}\doxysubsubsection{Braces \& Brackets}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32018}
This library attempts a quick and imperfect method of determining which path parts have glob magic without fully parsing/lexing the pattern. There are some advanced use cases that can trip it up, such as nested braces where the outer pair is escaped and the inner one contains a path separator. If you find yourself in the unlikely circumstance of being affected by this or need to ensure higher-\/fidelity glob handling in your library, it is recommended that you pre-\/process your input with \href{https://github.com/jonschlinkert/expand-braces}{\texttt{ expand-\/braces}} and/or \href{https://github.com/jonschlinkert/expand-brackets}{\texttt{ expand-\/brackets}}.\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32019}{}\doxysubsubsection{Windows}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32019}
Backslashes are not valid path separators for globs. If a path with backslashes is provided anyway, for simple cases, glob-\/parent will replace the path separator for you and return the non-\/glob parent path (now with forward-\/slashes, which are still valid as Windows path separators).

This cannot be used in conjunction with escape characters.


\begin{DoxyCode}{0}
\DoxyCodeLine{// BAD}
\DoxyCodeLine{globParent('C:\(\backslash\)\(\backslash\)Program Files \(\backslash\)\(\backslash\)(x86\(\backslash\)\(\backslash\))\(\backslash\)\(\backslash\)*.ext') // 'C:/Program Files /(x86/)'}
\DoxyCodeLine{}
\DoxyCodeLine{// GOOD}
\DoxyCodeLine{globParent('C:/Program Files\(\backslash\)\(\backslash\)(x86\(\backslash\)\(\backslash\))/*.ext') // 'C:/Program Files (x86)' }

\end{DoxyCode}


If you are using escape characters for a pattern without path parts (i.\+e. relative to {\ttfamily cwd}), prefix with {\ttfamily ./} to avoid confusing glob-\/parent.


\begin{DoxyCode}{0}
\DoxyCodeLine{// BAD}
\DoxyCodeLine{globParent('foo \(\backslash\)\(\backslash\)[bar]') // 'foo '}
\DoxyCodeLine{globParent('foo \(\backslash\)\(\backslash\)[bar]*') // 'foo '}
\DoxyCodeLine{}
\DoxyCodeLine{// GOOD}
\DoxyCodeLine{globParent('./foo \(\backslash\)\(\backslash\)[bar]') // 'foo [bar]'}
\DoxyCodeLine{globParent('./foo \(\backslash\)\(\backslash\)[bar]*') // '.' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32020}{}\doxysection{Change Log}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32020}
\href{https://github.com/es128/glob-parent/releases}{\texttt{ See release notes page on Git\+Hub}}\hypertarget{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32021}{}\doxysection{License}\label{md_sfcode_node_modules_watchpack_chokidar2_node_modules_glob_parent_README_autotoc_md32021}
\href{https://raw.github.com/es128/glob-parent/master/LICENSE}{\texttt{ ISC}} 