Skip to content

Commit 1947815

Browse files
committed
Add node_modules as a default exclude and add a skipDefaultExcludes option.
1 parent 1a0b2dd commit 1947815

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

c.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "./config-schema.json",
3+
"gatton.net": {
4+
"skipDefaultExcludes": true
5+
}
6+
}

config-schema.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@
1919
"properties": {
2020
"username": {
2121
"description": "SSH username for the deployment",
22-
"type": ["string"]
22+
"type": "string"
2323
},
2424
"fromLocalDir": {
2525
"description": "Deploy from this directory instead of the default. (Default example: https://example.com/path/to/dir → ./dist/web/example.com/path/to/dir).",
26-
"type": ["string"]
26+
"type": "string"
27+
},
28+
"skipDefaultExcludes": {
29+
"description": "Skip all default excludes, or a subset. If any paths are included in `additionalExcludes`, that overrides this setting.",
30+
"anyOf": [
31+
{
32+
"enum": [true]
33+
},
34+
{ "type": "array", "items": { "type": "string" } }
35+
]
2736
},
2837
"additionalExcludes": {
2938
"description": "A list of additional paths to exclude. (The following are always excluded: `.git`, `.DS_Store`.)",

src/lib/deploy.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { PrintableShellCommand } from "printable-shell-command";
22
import type { Args } from "./args";
33

4+
const DEFAULT_EXCLUDES = [".DS_Store", ".git", ".jj", "node_modules"];
5+
46
export interface TargetOptions {
57
username?: string;
68
fromLocalDir?: string;
9+
skipDefaultExcludes?: true | string[];
710
additionalExcludes?: string[];
811
}
912

1013
export const targetOptionsFields = {
1114
username: true,
1215
fromLocalDir: true,
16+
skipDefaultExcludes: true,
1317
additionalExcludes: true,
1418
}; // TODO: make this more DRY
1519

@@ -83,9 +87,14 @@ export async function deploy(
8387
// rsyncCommandArgs.push("--mkpath");
8488
// }
8589

86-
rsyncCommandArgs.push(["--exclude", ".git"]);
87-
rsyncCommandArgs.push(["--exclude", ".jj"]);
88-
rsyncCommandArgs.push(["--exclude", ".DS_Store"]);
90+
if (targetOptions?.skipDefaultExcludes !== true) {
91+
const toSkip = new Set(targetOptions?.skipDefaultExcludes ?? []);
92+
for (const pattern of DEFAULT_EXCLUDES) {
93+
if (!toSkip.has(pattern)) {
94+
rsyncCommandArgs.push(["--exclude", pattern]);
95+
}
96+
}
97+
}
8998
for (const additionalExclude of targetOptions?.additionalExcludes ?? []) {
9099
rsyncCommandArgs.push(["--exclude", additionalExclude]);
91100
}

0 commit comments

Comments
 (0)