Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ You can use the `-e` option to exclude some files from the pattern, so to exclud
copyfiles "**/*.test.js" -f ./foo/**/*.js out -e
```

> [!NOTE]
> By default the `.git/` and `node_modules/` directories will be excluded.

Other options include

- `-a` or `--all` which includes files that start with a dot.
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ export function copyfiles(paths: string[], options: CopyFileOptions, callback?:
createDir(dirname(outPath));
}

const globOptions: GlobOptions = {};
if (Array.isArray(options.exclude) && options.exclude.length > 0) {
globOptions.ignore = options.exclude;
}
const excludeGlobs = [
'**/.git/**',
'**/node_modules/**',
...(Array.isArray(options.exclude) && options.exclude.length > 0 ? options.exclude : []),
];
const globOptions: GlobOptions = { ignore: excludeGlobs };
if (options.all) {
globOptions.dot = true;
}
Expand Down