I'm trying to zip every file in my current directory to deploy.zip
using the command:
zip -r deploy.zip -x "**/node_modules/**"
This command doesn't work and still zips all the node_modules and it's descendant folders and files. This command is basically running on the GitHub Action panel.
What's wrong in here?
It looks like your exclude glob expression isn't quite right. The expression **/node_modules/**
looks for absolute filenames from the search path that has the string /node_modules/
to be present. But running the zip
from your current path won't include the leading /
for any of the file/directory names under node_modules
. I would suggest doing it as '*node_modules*'
or './node_modules/*'
or 'node_modules/*'
for your exclude path definition.
Also note that using **
in your glob pattern doesn't mean the same as using simple wild card expansion as *
. The former has a special meaning in zip
when --wild-stop-dirs
option is enabled. See zip(1) - Linux man page