Skip to content

Commit f9deea0

Browse files
committed
node: use fileSystem in BacktraceFileAttachment
1 parent d4719d6 commit f9deea0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/node/src/attachment/BacktraceFileAttachment.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import { BacktraceFileAttachment as CoreBacktraceFileAttachment } from '@backtra
22
import fs from 'fs';
33
import path from 'path';
44
import { Readable } from 'stream';
5+
import { NodeFileSystem } from '../storage/interfaces/NodeFileSystem';
56

67
export class BacktraceFileAttachment implements CoreBacktraceFileAttachment<Readable> {
78
public readonly name: string;
89

9-
constructor(public readonly filePath: string, name?: string) {
10+
constructor(public readonly filePath: string, name?: string, private readonly _fileSystem?: NodeFileSystem) {
1011
this.name = name ?? path.basename(this.filePath);
1112
}
1213

13-
public get(): fs.ReadStream | undefined {
14-
if (!fs.existsSync(this.filePath)) {
14+
public get(): Readable | undefined {
15+
if (!(this._fileSystem ?? fs).existsSync(this.filePath)) {
1516
return undefined;
1617
}
17-
return fs.createReadStream(this.filePath);
18+
return (this._fileSystem ?? fs).createReadStream(this.filePath);
1819
}
1920
}

0 commit comments

Comments
 (0)