Skip to content

Commit abc2439

Browse files
committed
fix: apply watch path negations as a pattern set
1 parent 5b6a8bd commit abc2439

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎apps/dokploy/__test__/deploy/should-deploy.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,30 @@ describe("shouldDeploy", () => {
1616
expect(shouldDeploy(["src/**"], ["docs/readme.md"])).toBe(false);
1717
});
1818

19+
it("should apply multiple negated watch paths as one pattern set", () => {
20+
const watchPaths = ["!CHANGELOG.md", "!VERSION", "!tests/**"];
21+
22+
expect(shouldDeploy(watchPaths, ["CHANGELOG.md"])).toBe(false);
23+
expect(shouldDeploy(watchPaths, ["VERSION"])).toBe(false);
24+
expect(shouldDeploy(watchPaths, ["tests/unit/example.test.ts"])).toBe(
25+
false,
26+
);
27+
});
28+
29+
it("should deploy when a changed file remains after exclusions", () => {
30+
const watchPaths = ["!CHANGELOG.md", "!VERSION", "!tests/**"];
31+
32+
expect(shouldDeploy(watchPaths, ["VERSION", "src/index.ts"])).toBe(true);
33+
});
34+
35+
it("should combine positive and negated watch paths", () => {
36+
const watchPaths = ["src/**", "!src/**/*.test.ts"];
37+
38+
expect(shouldDeploy(watchPaths, ["src/index.ts"])).toBe(true);
39+
expect(shouldDeploy(watchPaths, ["src/index.test.ts"])).toBe(false);
40+
expect(shouldDeploy(watchPaths, ["docs/readme.md"])).toBe(false);
41+
});
42+
1943
it("should not throw when modified files contain non-string values", () => {
2044
expect(() =>
2145
shouldDeploy(["src/**"], ["src/index.ts", undefined, null] as any),

‎packages/server/src/utils/watch-paths/should-deploy.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export const shouldDeploy = (
88
const files = (modifiedFiles ?? []).filter(
99
(file): file is string => typeof file === "string",
1010
);
11-
return micromatch.some(files, watchPaths);
11+
return micromatch(files, watchPaths).length > 0;
1212
};

0 commit comments

Comments
 (0)