Skip to content

Commit ef7d423

Browse files
committed
Abhi code review
1 parent a7d61df commit ef7d423

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/node/src/integrations/contextlines.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ import { Event, EventProcessor, Integration } from '@sentry/types';
33
import { addContextToFrame } from '@sentry/utils';
44
import { readFile } from 'fs';
55
import { LRUMap } from 'lru_map';
6+
import { promisify } from 'util';
67

78
import { NodeClient } from '../client';
89

910
const FILE_CONTENT_CACHE = new LRUMap<string, string | null>(100);
1011
const DEFAULT_LINES_OF_CONTEXT = 7;
1112

1213
function readTextFileAsync(path: string): Promise<string> {
13-
return new Promise((resolve, reject) => {
14-
readFile(path, 'utf8', (err, data) => {
15-
if (err) reject(err);
16-
else resolve(data);
17-
});
18-
});
14+
return promisify(readFile)(path, { encoding: 'utf8' });
1915
}
2016

2117
/**
@@ -28,10 +24,11 @@ export function resetFileContentCache(): void {
2824

2925
interface ContextLinesOptions {
3026
/**
31-
* Sets the number of context lines for each frame when loading a file
27+
* Sets the number of context lines for each frame when loading a file.
28+
* Defaults to 7.
3229
*
3330
* Set to 0 to disable loading and inclusion of source files.
34-
* */
31+
**/
3532
frameContextLines?: number;
3633
}
3734

0 commit comments

Comments
 (0)