Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpViewer/helpPreviewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class RLocalHelpPreviewer {

private readonly dummyPackageName: string;

constructor(options: RHelpPreviewerOptions, packageDir: string, unnamedId: number = 1){
constructor(options: RHelpPreviewerOptions, packageDir: string, unnamedId: number = 1) {
this.packageDir = packageDir;
this.descriptionPath = path.join(this.packageDir, 'DESCRIPTION');
this.manDir = path.join(this.packageDir, 'man');
Expand Down
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,18 +621,18 @@ export function readdirSyncSafe(

export function statSyncSafe(path: fs.PathLike): fs.Stats | undefined {
try {
return fs.statSync(path);
return fs.statSync(path, { throwIfNoEntry: false });
} catch (e) {

return undefined;
}
}

export function isDirSafe(path: fs.PathLike): boolean {
return !!fs.statSync(path, {throwIfNoEntry: false})?.isDirectory();
return !!statSyncSafe(path)?.isDirectory();
}

export function isFileSafe(path: fs.PathLike): boolean {
return !!fs.statSync(path, {throwIfNoEntry: false})?.isFile();
return !!statSyncSafe(path)?.isFile();
}

// Keeps only the unique entries in an array, optionally with a custom comparison function
Expand Down