Ensures that the file exists. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is {\bfseries{NOT MODIFIED}}.

{\bfseries{Alias\+:}} {\ttfamily create\+File()}


\begin{DoxyItemize}
\item {\ttfamily file} {\ttfamily $<$String$>$}
\item {\ttfamily callback} {\ttfamily $<$Function$>$}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_fs_extra_docs_ensureFile_autotoc_md11005}{}\doxysection{Example\+:}\label{md_sfcode_node_modules_fs_extra_docs_ensureFile_autotoc_md11005}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fs = require('fs-\/extra')}
\DoxyCodeLine{}
\DoxyCodeLine{const file = '/tmp/this/path/does/not/exist/file.txt'}
\DoxyCodeLine{fs.ensureFile(file, err => \{}
\DoxyCodeLine{  console.log(err) // => null}
\DoxyCodeLine{  // file has now been created, including the directory it is to be placed in}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// With Promises:}
\DoxyCodeLine{fs.ensureFile(file)}
\DoxyCodeLine{.then(() => \{}
\DoxyCodeLine{  console.log('success!')}
\DoxyCodeLine{\})}
\DoxyCodeLine{.catch(err => \{}
\DoxyCodeLine{  console.error(err)}
\DoxyCodeLine{\}) }

\end{DoxyCode}
 