Copy a file or directory. The directory can have contents. Like {\ttfamily cp -\/r}.


\begin{DoxyItemize}
\item {\ttfamily src} {\ttfamily $<$String$>$}
\item {\ttfamily dest} {\ttfamily $<$String$>$}
\item {\ttfamily options} {\ttfamily $<$Object$>$}
\begin{DoxyItemize}
\item {\ttfamily overwrite} {\ttfamily $<$boolean$>$}\+: overwrite existing file or directory, default is {\ttfamily true}. {\itshape Note that the copy operation will silently fail if you set this to {\ttfamily false} and the destination exists.} Use the {\ttfamily error\+On\+Exist} option to change this behavior.
\item {\ttfamily error\+On\+Exist} {\ttfamily $<$boolean$>$}\+: when {\ttfamily overwrite} is {\ttfamily false} and the destination exists, throw an error. Default is {\ttfamily false}.
\item {\ttfamily dereference} {\ttfamily $<$boolean$>$}\+: dereference symlinks, default is {\ttfamily false}.
\item {\ttfamily preserve\+Timestamps} {\ttfamily $<$boolean$>$}\+: will set last modification and access times to the ones of the original source files, default is {\ttfamily false}.
\item {\ttfamily filter} {\ttfamily $<$Function$>$}\+: Function to filter copied files. Return {\ttfamily true} to include, {\ttfamily false} to exclude. This can also be a Reg\+Exp, however this is deprecated (See \href{https://github.com/jprichardson/node-fs-extra/issues/239}{\texttt{ issue \#239}} for background).
\end{DoxyItemize}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_fs_extra_docs_copy_sync_autotoc_md10991}{}\doxysection{Example\+:}\label{md_sfcode_node_modules_fs_extra_docs_copy_sync_autotoc_md10991}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fs = require('fs-\/extra')}
\DoxyCodeLine{}
\DoxyCodeLine{// copy file}
\DoxyCodeLine{fs.copySync('/tmp/myfile', '/tmp/mynewfile')}
\DoxyCodeLine{}
\DoxyCodeLine{// copy directory, even if it has subdirectories or files}
\DoxyCodeLine{fs.copySync('/tmp/mydir', '/tmp/mynewdir') }

\end{DoxyCode}


{\bfseries{Using filter function}}


\begin{DoxyCode}{0}
\DoxyCodeLine{const fs = require('fs-\/extra')}
\DoxyCodeLine{}
\DoxyCodeLine{const filterFunc = (src, dest) => \{}
\DoxyCodeLine{  // your logic here}
\DoxyCodeLine{  // it will be copied if return true}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{fs.copySync('/tmp/mydir', '/tmp/mynewdir', \{ filter: filterFunc \}) }

\end{DoxyCode}
 