0

I'm trying to copy the yaml files in my project to a dist folder, preserving the structure. However it is copying node_modules which I don't want. How do I exclude with rsync and why does my below command not work?

rsync -R --exclude=node_modules ./**/**.yaml dist

Note I've tried the variants, etc:

rsync -R --exclude= node_modules ./**/**.yaml dist
rsync -R --exclude 'node_modules' ./**/**.yaml dist

my folder structure:

projectroot
|--config/file.yaml
|
|--node_modules/somedir/somefile.yaml
|
|--src/somefolder/somefile.yaml

and I want the above to show up in my dist as:

dist
|--config/file.yaml
|  
|--src/somefolder/somefile.yaml
1

I ended up going with:

rsync -avrmR --exclude='node_modules/' --include='*/' --include='*.yaml' --exclude='*' ./ ./dist

How it works is it first excludes anything in the node_modules folder, then includes all directories and then includes only yaml files and then excludes everything else.

0

I have managed to get this working as follow:

$ rsync -r --exclude="node_modules" projectroot/* dist/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.