Skip to content

Commit 7f3a4c9

Browse files
authored
fix: .git and node_modules should be excluded by default (#34)
1 parent 0bb0c20 commit 7f3a4c9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ You can use the `-e` option to exclude some files from the pattern, so to exclud
107107
copyfiles "**/*.test.js" -f ./foo/**/*.js out -e
108108
```
109109

110+
> [!NOTE]
111+
> By default the `.git/` and `node_modules/` directories will be excluded.
112+
110113
Other options include
111114

112115
- `-a` or `--all` which includes files that start with a dot.

src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,12 @@ export function copyfiles(paths: string[], options: CopyFileOptions, callback?:
158158
createDir(dirname(outPath));
159159
}
160160

161-
const globOptions: GlobOptions = {};
162-
if (Array.isArray(options.exclude) && options.exclude.length > 0) {
163-
globOptions.ignore = options.exclude;
164-
}
161+
const excludeGlobs = [
162+
'**/.git/**',
163+
'**/node_modules/**',
164+
...(Array.isArray(options.exclude) && options.exclude.length > 0 ? options.exclude : []),
165+
];
166+
const globOptions: GlobOptions = { ignore: excludeGlobs };
165167
if (options.all) {
166168
globOptions.dot = true;
167169
}

0 commit comments

Comments
 (0)