\href{https://travis-ci.com/npm/npm-packlist}{\texttt{ }}

Get a list of the files to add from a folder into an npm package

These can be handed to \href{http://npm.im/tar}{\texttt{ tar}} like so to make an npm package tarball\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const packlist = require('npm-\/packlist')}
\DoxyCodeLine{const tar = require('tar')}
\DoxyCodeLine{const packageDir = '/path/to/package'}
\DoxyCodeLine{const packageTarball = '/path/to/package.tgz'}
\DoxyCodeLine{}
\DoxyCodeLine{packlist(\{ path: packageDir \})}
\DoxyCodeLine{  .then(files => tar.create(\{}
\DoxyCodeLine{    prefix: 'package/',}
\DoxyCodeLine{    cwd: packageDir,}
\DoxyCodeLine{    file: packageTarball,}
\DoxyCodeLine{    gzip: true}
\DoxyCodeLine{  \}, files))}
\DoxyCodeLine{  .then(\_ => \{}
\DoxyCodeLine{    // tarball has been created, continue with your day}
\DoxyCodeLine{  \}) }

\end{DoxyCode}


This uses the following rules\+:


\begin{DoxyEnumerate}
\item If a {\ttfamily package.\+json} file is found, and it has a {\ttfamily files} list, then ignore everything that isn\textquotesingle{}t in {\ttfamily files}. Always include the readme, license, notice, changes, changelog, and history files, if they exist, and the package.\+json file itself.
\item If there\textquotesingle{}s no {\ttfamily package.\+json} file (or it has no {\ttfamily files} list), and there is a {\ttfamily .npmignore} file, then ignore all the files in the {\ttfamily .npmignore} file.
\item If there\textquotesingle{}s no {\ttfamily package.\+json} with a {\ttfamily files} list, and there\textquotesingle{}s no {\ttfamily .npmignore} file, but there is a {\ttfamily .gitignore} file, then ignore all the files in the {\ttfamily .gitignore} file.
\item Everything in the root {\ttfamily node\+\_\+modules} is ignored, unless it\textquotesingle{}s a bundled dependency. If it IS a bundled dependency, and it\textquotesingle{}s a symbolic link, then the target of the link is included, not the symlink itself.
\end{DoxyEnumerate}
\begin{DoxyEnumerate}
\item Unless they\textquotesingle{}re explicitly included (by being in a {\ttfamily files} list, or a {\ttfamily !negated} rule in a relevant {\ttfamily .npmignore} or {\ttfamily .gitignore}), always ignore certain common cruft files\+:
\begin{DoxyEnumerate}
\item .npmignore and .gitignore files (their effect is in the package already, there\textquotesingle{}s no need to include them in the package)
\item editor junk like {\ttfamily .$\ast$.swp}, {\ttfamily .\+\_\+$\ast$} and {\ttfamily .$\ast$.orig} files
\item {\ttfamily .npmrc} files (these may contain private configs)
\item The {\ttfamily node\+\_\+modules/.bin} folder
\item Waf and gyp cruft like {\ttfamily /build/config.gypi} and {\ttfamily .lock-\/wscript}
\item Darwin\textquotesingle{}s {\ttfamily .DS\+\_\+\+Store} files because wtf are those even
\item {\ttfamily npm-\/debug.\+log} files at the root of a project
\end{DoxyEnumerate}

You can explicitly re-\/include any of these with a {\ttfamily files} list in {\ttfamily package.\+json} or a negated ignore file rule.
\end{DoxyEnumerate}\hypertarget{md_sfcode_node_modules_npm_packlist_README_autotoc_md18426}{}\doxysection{API}\label{md_sfcode_node_modules_npm_packlist_README_autotoc_md18426}
Same API as \href{http://npm.im/ignore-walk}{\texttt{ ignore-\/walk}}, just hard-\/coded file list and rule sets.

The {\ttfamily Walker} and {\ttfamily Walker\+Sync} classes take a {\ttfamily bundled} argument, which is a list of package names to include from node\+\_\+modules. When calling the top-\/level {\ttfamily packlist()} and {\ttfamily packlist.\+sync()} functions, this module calls into {\ttfamily npm-\/bundled} directly. 