Skip to content

Commit

Permalink
feat: exclude common unnecessary files by default (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmokmss authored Oct 30, 2024
1 parent 8d90902 commit c2d1940
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
14 changes: 14 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/nodejs-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ export interface NodejsBuildProps {
* @default false
*/
readonly outputEnvFile?: boolean;
/**
* If true, common unnecessary files/directories such as .DS_Store, .git, node_modules, etc are excluded
* from the assets by default.
* @default true
*/
readonly excludeCommonFiles?: boolean;
}

/**
Expand Down Expand Up @@ -229,9 +235,11 @@ curl -v -i -X PUT -H 'Content-Type:' -d "@payload.json" "$responseURL"

this.grantPrincipal = project.grantPrincipal;

const commonExclude = ['.DS_Store', '.git', 'node_modules'];
const assets = props.assets.map((assetProps) => {
const asset = new Asset(this, `Source-${assetProps.path.replace('/', '')}`, {
...assetProps,
...(props.excludeCommonFiles ?? true ? { exclude: [...commonExclude, ...(assetProps.exclude ?? [])] } : {}),
});
asset.grantRead(project);
return asset;
Expand Down
2 changes: 1 addition & 1 deletion test/integ.nodejs-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestStack extends Stack {
assets: [
{
path: '../example/example-app',
exclude: ['dist', 'node_modules'],
exclude: ['dist'],
},
],
destinationBucket: dstBucket,
Expand Down

0 comments on commit c2d1940

Please sign in to comment.