Skip to content

Commit

Permalink
fix(windows): fix excludes and filename anchoring
Browse files Browse the repository at this point in the history
Without this, filenames could be matched in any directory. Now the
file list is explicit about file locations. We thus don't need any
explicit excludes either.

The same issue was not found on other platforms, but it's possible this
also fixes potential issues on *nix platforms.
  • Loading branch information
edvald committed Nov 14, 2019
1 parent 68ba910 commit b3539c3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions garden-service/src/build-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,7 @@ export class BuildDir {
sourcePath = stripWildcard(sourcePath)
destinationPath = stripWildcard(destinationPath)

// --exclude is required for modules where the module and project are in the same directory
const syncOpts = [
"-rptgo",
`--exclude=${this.buildDirPath}`,
"--ignore-missing-args",
"--temp-dir",
normalizeLocalRsyncPath(tmpDir),
]
const syncOpts = ["-rptgo", "--ignore-missing-args", "--temp-dir", normalizeLocalRsyncPath(tmpDir)]

let logMsg =
`Syncing ${module.version.files.length} files from ` +
Expand All @@ -192,6 +185,10 @@ export class BuildDir {
} else {
// Workaround for this issue: https://stackoverflow.com/questions/1813907
syncOpts.push("--include-from=-", "--exclude=*", "--delete-excluded")

// -> Make sure the file list is anchored (otherwise filenames are matched as patterns)
files = files.map((f) => "/" + f)

input = "/**/\n" + files.join("\n")
}
} else if (files !== undefined) {
Expand All @@ -202,6 +199,7 @@ export class BuildDir {
// Avoid rendering the full file list except when at the silly log level
if (log.root.level === LogLevel.silly) {
log.silly(`File list: ${JSON.stringify(files)}`)
log.silly(`Rsync args: ${[...syncOpts, sourcePath, destinationPath].join(" ")}`)
}

await exec("rsync", [...syncOpts, sourcePath, destinationPath], { input })
Expand Down

0 comments on commit b3539c3

Please sign in to comment.