Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit 64481f8

Browse files
SiebeVEgregberge
authored andcommitted
feat(shipit-deploy): Added config so you can rsync including the folder (#246)
1 parent ba1d8c2 commit 64481f8

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

packages/shipit-deploy/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ module.exports = shipit => {
4040
deleteOnRollback: false,
4141
key: '/path/to/key',
4242
shallowClone: true,
43+
deploy: {
44+
remoteCopy: {
45+
copyAsDir: false, // Should we copy as the dir (true) or the content of the dir (false)
46+
},
47+
},
4348
},
4449
staging: {
4550
servers: '[email protected]',
@@ -176,6 +181,12 @@ Type: `String`
176181

177182
Parameter to pass to `cp` to copy the previous release. Non NTFS filesystems support `-r`. Default: `-a`
178183

184+
### deploy.remoteCopy.copyAsDir
185+
186+
Type: `Boolean` _Optional_
187+
188+
If `true` - We will copy the folder instead of the content of the folder. Default: `false`.
189+
179190
## Variables
180191

181192
Several variables are attached during the deploy and the rollback process:

packages/shipit-deploy/src/tasks/deploy/update.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ const updateTask = shipit => {
6767

6868
shipit.log('Copy project to remote servers.')
6969

70-
await shipit.remoteCopy(`${uploadDirPath}/`, shipit.releasePath, options)
70+
let srcDirectory = `${uploadDirPath}/`;
71+
if(options.copyAsDir){
72+
srcDirectory = srcDirectory.slice(0, -1);
73+
}
74+
await shipit.remoteCopy(srcDirectory, shipit.releasePath, options)
7175
shipit.log(chalk.green('Finished copy.'))
7276
}
7377

packages/shipit-deploy/src/tasks/deploy/update.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ describe('deploy:update task', () => {
124124
)
125125
})
126126
})
127+
128+
it('should accept rsync options', async () => {
129+
const sh = createShipitInstance({
130+
deploy: { remoteCopy: { rsync: '--foo', copyAsDir: true } },
131+
})
132+
stubShipit(sh)
133+
134+
await start(sh, 'deploy:update')
135+
136+
expect(sh.remoteCopy).toBeCalledWith(
137+
'/tmp/workspace',
138+
'/remote/deploy/releases/YYYYMMDDHHmmss',
139+
{ rsync: '--foo', copyAsDir: true },
140+
)
141+
})
127142
})
128143

129144
describe('#setPreviousRevision', () => {

0 commit comments

Comments
 (0)