From 728d68ad3dfeb86de6d319f05435a6ac7319232e Mon Sep 17 00:00:00 2001 From: Mohamed Akram Date: Wed, 3 Jan 2024 20:25:41 +0400 Subject: [PATCH] fix: handling of directory glob (#214) ## References Fixes #212 --- lib/index.js | 5 +++-- test/package-json-directory-glob.js | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index e46ea7e..985f11e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -298,8 +298,9 @@ class PackWalker extends IgnoreWalker { // invert the rule because these are things we want to include if (file.startsWith('./')) { file = file.slice(1) - } else if (file.endsWith('/*')) { - file = file.slice(0, -1) + } + if (file.endsWith('/*')) { + file += '*' } const inverse = `!${file}` try { diff --git a/test/package-json-directory-glob.js b/test/package-json-directory-glob.js index 48b228d..ab68428 100644 --- a/test/package-json-directory-glob.js +++ b/test/package-json-directory-glob.js @@ -24,6 +24,8 @@ t.test('package json directory glob', async (t) => { 'folder/', 'folder/*', 'folder/**', + 'folder/**/*', + './folder/*', ] for (const files of pkgFiles) {