Say I have a .gitignore or .npmignore file with the following contents:
logs
*.sh
*.log
not that .npmignore files are designed to be interpreted just like .gitignore files.
My question is - how can I use the contents of a standard .npmignore / .gitignore file and map them to --exclude
options for a tar command?
basically I need to do something like this:
find -not -path (whatever is in gitignore) | tar
or just this:
tar --exclude="whatever matches gitignore/npmignore"
the latter just seems fine, but how can I map what's in .gitignore / .npmignore to the command line? Is there some package that can do that?
As I suspected, it looks .gitignore / .npmignore are designed to map directly to command line tools, like
find
,tar
, etc.So in Node.js/TypeScript code, I just have this, and it seems to work: