diff --git a/README.md b/README.md index 0991629..061901a 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/index.ts b/src/index.ts index c42f3fa..c2924b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; }