Skip to content

Commit

Permalink
fix(core): exclude garden dir in Garden factory (TBS)
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Aug 6, 2019
1 parent 8f918c4 commit 716671a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion garden-service/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ export class Garden {
const buildDir = await BuildDir.factory(projectRoot, gardenDirPath)
const workingCopyId = await getWorkingCopyId(gardenDirPath)

// We always exclude the garden dir
const gardenDirExcludePattern = `${relative(projectRoot, gardenDirPath)}/**/*`
const moduleExcludePatterns = [...((config.modules || {}).exclude || []), gardenDirExcludePattern]

const garden = new this({
projectRoot,
projectName,
Expand All @@ -230,10 +234,10 @@ export class Garden {
opts,
plugins,
providerConfigs: providers,
moduleExcludePatterns,
workingCopyId,
dotIgnoreFiles: config.dotIgnoreFiles,
moduleIncludePatterns: (config.modules || {}).include,
moduleExcludePatterns: (config.modules || {}).exclude,
}) as InstanceType<T>

return garden
Expand Down
1 change: 0 additions & 1 deletion garden-service/src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { VcsHandler } from "../vcs/vcs"
const VALID_CONFIG_FILENAMES = ["garden.yml", "garden.yaml"]
const metadataFilename = "metadata.json"
export const defaultDotIgnoreFiles = [".gitignore", ".gardenignore"]
// FIXME: We should use `garden.gardenDirPath` instead of ".garden" since the gardenDirPath property is configurable.
export const fixedExcludes = [".git", ".garden/**/*", "debug-info*/**"]

/*
Expand Down
9 changes: 9 additions & 0 deletions garden-service/test/unit/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ describe("Garden", () => {
expect(garden).to.be.ok
})

it("should always exclude the garden dir", async () => {
const gardenA = await makeTestGardenA()
const gardenCustomDir = await makeTestGarden(getDataDir("test-project-a"), {
gardenDirPath: "custom/garden-dir",
})
expect(gardenA.moduleExcludePatterns).to.include(".garden/**/*")
expect(gardenCustomDir.moduleExcludePatterns).to.include("custom/garden-dir/**/*")
})

it("should throw if a project has config files with yaml and yml extensions in the same dir", async () => {
const path = getDataDir("test-project-duplicate-yaml-file-extensions")
await expectError(async () => makeTestGarden(path), "validation")
Expand Down

0 comments on commit 716671a

Please sign in to comment.