Skip to content

Commit 93960c6

Browse files
committed
Change _attachmentsFromScope return type
1 parent 23e1f90 commit 93960c6

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

packages/core/src/baseclient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,8 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
664664
/**
665665
* Loads attachment items from scope
666666
*/
667-
protected _attachmentsFromScope(scope: Scope | undefined): AttachmentItem[] | undefined {
668-
return scope?.getAttachments()?.map(a => createAttachmentEnvelopeItem(a));
667+
protected _attachmentsFromScope(scope: Scope | undefined): AttachmentItem[] {
668+
return scope?.getAttachments()?.map(a => createAttachmentEnvelopeItem(a)) || [];
669669
}
670670

671671
/**

packages/node/src/client.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,19 @@ export class NodeClient extends BaseClient<NodeClientOptions> {
155155
/**
156156
* @inheritDoc
157157
*/
158-
protected _attachmentsFromScope(scope: Scope | undefined): AttachmentItem[] | undefined {
159-
return scope?.getAttachments()?.map(attachment => {
160-
let [pathOrData, options] = attachment;
161-
162-
if (typeof pathOrData === 'string' && existsSync(pathOrData)) {
163-
options = options || {};
164-
options.filename = basename(pathOrData);
165-
pathOrData = readFileSync(pathOrData);
166-
}
158+
protected _attachmentsFromScope(scope: Scope | undefined): AttachmentItem[] {
159+
return (
160+
scope?.getAttachments()?.map(attachment => {
161+
let [pathOrData, options] = attachment;
162+
163+
if (typeof pathOrData === 'string' && existsSync(pathOrData)) {
164+
options = options || {};
165+
options.filename = basename(pathOrData);
166+
pathOrData = readFileSync(pathOrData);
167+
}
167168

168-
return createAttachmentEnvelopeItem([pathOrData, options]);
169-
});
169+
return createAttachmentEnvelopeItem([pathOrData, options]);
170+
}) || []
171+
);
170172
}
171173
}

0 commit comments

Comments
 (0)