Skip to content

Commit

Permalink
refactor: define property and not set it
Browse files Browse the repository at this point in the history
  • Loading branch information
blacha committed Aug 22, 2024
1 parent f31489a commit 42c7059
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/source-aws/src/__test__/source.aws.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ describe('SourceAwsS3', () => {
});

it('should not expose "client" for logging', () => {
const keys = Object.keys(new SourceAwsS3('s3://foo/bar.txt'));
const source = new SourceAwsS3('s3://foo/bar.txt');
const keys = Object.keys(source);
assert.equal(keys.includes('client'), false);
assert.notEqual(source.client.config, null);
});
});
8 changes: 2 additions & 6 deletions packages/source-aws/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,9 @@ export class SourceAwsS3 implements Source {

constructor(url: URL | string, client: S3Client = new S3Client({})) {
this.url = typeof url === 'string' ? new URL(url) : url;
// Make typescript happy
// S3 clients are very large and if this object gets logged the log is very very large
Object.defineProperty(this, 'client', { enumerable: false });
this.client = client;
// S3 clients are very large and if this object gets logged the client is very very large
Object.defineProperty(this, 'client', {
enumerable: false,
value: client,
});
}

_head?: Promise<SourceMetadata>;
Expand Down

0 comments on commit 42c7059

Please sign in to comment.