From 314ec7e64245f86663c8ca20fad05ebb5a390d80 Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 10 Apr 2024 10:26:05 -0700 Subject: [PATCH] list: close file even if no error thrown Fix: #404 --- src/list.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/list.ts b/src/list.ts index 7ba43143..9173edaa 100644 --- a/src/list.ts +++ b/src/list.ts @@ -130,7 +130,6 @@ const filesFilter = (opt: TarOptions, files: string[]) => { const listFileSync = (opt: TarOptionsSyncFile) => { const p = list_(opt) const file = opt.file - let threw = true let fd try { const stat = fs.statSync(file) @@ -148,9 +147,8 @@ const listFileSync = (opt: TarOptionsSyncFile) => { } p.end() } - threw = false } finally { - if (threw && fd) { + if (typeof fd === 'number') { try { fs.closeSync(fd) /* c8 ignore next */