la-haute-societe / ssh-deploy-release

Deploy releases over SSH with rsync, archive ZIP / TAR, symlinks, SCP ...
https://www.npmjs.com/package/ssh-deploy-release
MIT License
36 stars 10 forks source link

Simplify rsync excludes #13

Closed nstCactus closed 5 years ago

nstCactus commented 5 years ago

Requiring another way to set excludes for synchronize mode (rsync) is error prone.

The rsync command has an --exclude switch that can be called several times to exclude different files and folders :

rsync -a --exclude media --exclude storage/ --exclude some/deep/directory

This works for files & directories, so we could just build a list of --exclude switches from the exclude option form the configuration.

The only pitfall is that it doesn't support the glob syntax: --exclude craft/storage/** or --exclude craft/storage/* doesn't work, you have to use either --exclude craft/storage/ or --exclude craft/storage. To avoid headaches we should advise in the exclude option documentation to use both the glob and the rsync syntax to exclude a directory:

{
    ...
    exclude: [
        'craft/storage/**', // Glob syntax
        'craft/storage/',   // rsync syntax
    ],
    ...
}

Another option would be to rewrite the excludes written in glob syntax when using the synchronize mode but it seems like a bad idea.