diff --git a/src/helpViewer/helpPreviewer.ts b/src/helpViewer/helpPreviewer.ts index 006427bb5..75268f7da 100644 --- a/src/helpViewer/helpPreviewer.ts +++ b/src/helpViewer/helpPreviewer.ts @@ -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'); diff --git a/src/util.ts b/src/util.ts index ce4872b2e..0d8ef7995 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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