rsync 排除文件夹不起作用?

Ter*_*how 6 rsync

我正在尝试将项目中的 yaml 文件复制到 dist 文件夹,保留结构。然而它是node_modules我不想要的复制。如何使用 rsync 排除以及为什么我的以下命令不起作用?

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

注意我已经尝试过变体等:

rsync -R --exclude= node_modules ./**/**.yaml dist
rsync -R --exclude 'node_modules' ./**/**.yaml dist
Run Code Online (Sandbox Code Playgroud)

我的文件夹结构:

projectroot
|--config/file.yaml
|
|--node_modules/somedir/somefile.yaml
|
|--src/somefolder/somefile.yaml
Run Code Online (Sandbox Code Playgroud)

我希望以上内容在我的 dist 中显示为:

dist
|--config/file.yaml
|  
|--src/somefolder/somefile.yaml
Run Code Online (Sandbox Code Playgroud)

小智 3

我已经设法让这个工作如下:

$ rsync -r --exclude="node_modules" projectroot/* dist/
Run Code Online (Sandbox Code Playgroud)