diff --git a/garden-service/src/util/fs.ts b/garden-service/src/util/fs.ts index 45d7df8d02..de9ce5cc5e 100644 --- a/garden-service/src/util/fs.ts +++ b/garden-service/src/util/fs.ts @@ -196,7 +196,7 @@ export async function listDirectory(path: string): Promise { * Given a list of `paths`, return a list of paths that match any of the given `patterns` */ export function matchGlobs(paths: string[], patterns: string[]): string[] { - return paths.filter((path) => some(patterns, (pattern) => minimatch(path, pattern))) + return paths.filter((path) => some(patterns, (pattern) => minimatch(path, pattern, { dot: true }))) } /** diff --git a/garden-service/test/data/test-projects/build-dir/hidden-files/.hidden-dir/something b/garden-service/test/data/test-projects/build-dir/hidden-files/.hidden-dir/something new file mode 100644 index 0000000000..e69de29bb2 diff --git a/garden-service/test/data/test-projects/build-dir/hidden-files/.hidden-file b/garden-service/test/data/test-projects/build-dir/hidden-files/.hidden-file new file mode 100644 index 0000000000..e69de29bb2 diff --git a/garden-service/test/data/test-projects/build-dir/hidden-files/garden.yml b/garden-service/test/data/test-projects/build-dir/hidden-files/garden.yml new file mode 100644 index 0000000000..43db4005de --- /dev/null +++ b/garden-service/test/data/test-projects/build-dir/hidden-files/garden.yml @@ -0,0 +1,3 @@ +kind: Module +type: exec +name: hidden-files diff --git a/garden-service/test/unit/src/build-dir.ts b/garden-service/test/unit/src/build-dir.ts index 639a570084..1613709a2f 100644 --- a/garden-service/test/unit/src/build-dir.ts +++ b/garden-service/test/unit/src/build-dir.ts @@ -157,6 +157,17 @@ describe("BuildDir", () => { expect(await pathExists(deleteMe)).to.be.false }) + it("should sync hidden files and directories (names starting with .)", async () => { + const graph = await garden.getConfigGraph(garden.log) + const module = await graph.getModule("hidden-files") + + await garden.buildDir.syncFromSrc(module, garden.log) + + const buildDir = await garden.buildDir.buildPath(module) + expect(await pathExists(join(buildDir, ".hidden-file"))).to.be.true + expect(await pathExists(join(buildDir, ".hidden-dir", "something"))).to.be.true + }) + it("should sync symlinks that point within the module root", async () => { const graph = await garden.getConfigGraph(garden.log) const module = await graph.getModule("symlink-within-module") diff --git a/garden-service/test/unit/src/vcs/git.ts b/garden-service/test/unit/src/vcs/git.ts index 8f1440af8d..b05cffb1a0 100644 --- a/garden-service/test/unit/src/vcs/git.ts +++ b/garden-service/test/unit/src/vcs/git.ts @@ -229,6 +229,14 @@ describe("GitHandler", () => { expect(await handler.getFiles({ path: tmpPath, include: ["foo.*"], exclude: [], log })).to.eql([{ path, hash }]) }) + it("should include hidden files that match the include filter, if specified", async () => { + const path = resolve(tmpPath, ".foo") + const hash = "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391" + await createFile(path) + + expect(await handler.getFiles({ path: tmpPath, include: ["*"], exclude: [], log })).to.eql([{ path, hash }]) + }) + it("should filter out files that match the exclude filter, if specified", async () => { const path = resolve(tmpPath, "foo.txt") await createFile(path)