From df92e643b61ff8368ff36fef67b4818a598b4ac5 Mon Sep 17 00:00:00 2001 From: epolon Date: Sun, 20 Mar 2022 19:29:01 +0200 Subject: [PATCH] ignore empty dirs as well --- tools/@aws-cdk/node-bundle/src/api/bundle.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/@aws-cdk/node-bundle/src/api/bundle.ts b/tools/@aws-cdk/node-bundle/src/api/bundle.ts index 8b27644c83ff5..b1356ed6a6505 100644 --- a/tools/@aws-cdk/node-bundle/src/api/bundle.ts +++ b/tools/@aws-cdk/node-bundle/src/api/bundle.ts @@ -224,9 +224,12 @@ export class Bundle { const target = fs.mkdtempSync(path.join(os.tmpdir(), 'bundle-write-')); + // we definitely don't need these directories in the package + // so no need to copy them over. + const ignoreDirectories = ['node_modules', '.git']; + // copy the entire project since we are retaining the original files. - // except for `node_modules` and `.git` directories which definitely don't belong in the package. - fs.copySync(this.packageDir, target, { filter: n => !n.includes(`node_modules${path.sep}`) && !n.includes(`.git${path.sep}`) }); + fs.copySync(this.packageDir, target, { filter: n => !n.split(path.sep).some((p => ignoreDirectories.includes(p))) }); // clone the original manifest since we are going to // to mutate it.