Skip to content

Commit

Permalink
Merge pull request #638 from garden-io/fix-dep-sync
Browse files Browse the repository at this point in the history
fix(build): don't delete when syncing dependencies
  • Loading branch information
thsig authored Mar 18, 2019
2 parents 5453f4f + a5e12a7 commit 1b74573
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions garden-service/src/build-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class BuildDir {
await this.sync(
resolve(this.projectRoot, module.path) + sep,
await this.buildPath(module.name),
true,
)
}

Expand Down Expand Up @@ -83,7 +84,7 @@ export class BuildDir {

const sourcePath = join(sourceBuildPath, copy.source)
const destinationPath = join(buildPath, copy.target)
return this.sync(sourcePath, destinationPath)
return this.sync(sourcePath, destinationPath, false)
})
})
}
Expand All @@ -108,7 +109,12 @@ export class BuildDir {
return path
}

private async sync(sourcePath: string, destinationPath: string): Promise<void> {
/**
* Syncs sourcePath with destinationPath using rsync.
*
* If withDelete = true, files/folders in destinationPath that are not in sourcePath will also be deleted.
*/
private async sync(sourcePath: string, destinationPath: string, withDelete: boolean): Promise<void> {
const destinationDir = parse(destinationPath).dir
await ensureDir(destinationDir)

Expand All @@ -123,7 +129,11 @@ export class BuildDir {
destinationPath = stripWildcard(destinationPath)

// --exclude is required for modules where the module and project are in the same directory
await execa("rsync", ["-rptgo", "--delete", `--exclude=${GARDEN_DIR_NAME}`, sourcePath, destinationPath])
const syncOpts = ["-rptgo", `--exclude=${GARDEN_DIR_NAME}`]
if (withDelete) {
syncOpts.push("--delete")
}
await execa("rsync", [...syncOpts, sourcePath, destinationPath])
}
}

Expand Down

0 comments on commit 1b74573

Please sign in to comment.