diff --git a/packages/shipit-deploy/README.md b/packages/shipit-deploy/README.md index 544364c..d455aa5 100644 --- a/packages/shipit-deploy/README.md +++ b/packages/shipit-deploy/README.md @@ -40,6 +40,11 @@ module.exports = shipit => { deleteOnRollback: false, key: '/path/to/key', shallowClone: true, + deploy: { + remoteCopy: { + copyAsDir: false, // Should we copy as the dir (true) or the content of the dir (false) + }, + }, }, staging: { servers: 'user@myserver.com', @@ -176,6 +181,12 @@ Type: `String` Parameter to pass to `cp` to copy the previous release. Non NTFS filesystems support `-r`. Default: `-a` +### deploy.remoteCopy.copyAsDir + +Type: `Boolean` _Optional_ + +If `true` - We will copy the folder instead of the content of the folder. Default: `false`. + ## Variables Several variables are attached during the deploy and the rollback process: diff --git a/packages/shipit-deploy/src/tasks/deploy/update.js b/packages/shipit-deploy/src/tasks/deploy/update.js index 573da86..9caeab0 100644 --- a/packages/shipit-deploy/src/tasks/deploy/update.js +++ b/packages/shipit-deploy/src/tasks/deploy/update.js @@ -67,7 +67,11 @@ const updateTask = shipit => { shipit.log('Copy project to remote servers.') - await shipit.remoteCopy(`${uploadDirPath}/`, shipit.releasePath, options) + let srcDirectory = `${uploadDirPath}/`; + if(options.copyAsDir){ + srcDirectory = srcDirectory.slice(0, -1); + } + await shipit.remoteCopy(srcDirectory, shipit.releasePath, options) shipit.log(chalk.green('Finished copy.')) } diff --git a/packages/shipit-deploy/src/tasks/deploy/update.test.js b/packages/shipit-deploy/src/tasks/deploy/update.test.js index e10ceef..f633291 100644 --- a/packages/shipit-deploy/src/tasks/deploy/update.test.js +++ b/packages/shipit-deploy/src/tasks/deploy/update.test.js @@ -124,6 +124,21 @@ describe('deploy:update task', () => { ) }) }) + + it('should accept rsync options', async () => { + const sh = createShipitInstance({ + deploy: { remoteCopy: { rsync: '--foo', copyAsDir: true } }, + }) + stubShipit(sh) + + await start(sh, 'deploy:update') + + expect(sh.remoteCopy).toBeCalledWith( + '/tmp/workspace', + '/remote/deploy/releases/YYYYMMDDHHmmss', + { rsync: '--foo', copyAsDir: true }, + ) + }) }) describe('#setPreviousRevision', () => {