From a12275b2a055bd7b45844af13d9bee915d8f2248 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 28 Dec 2024 00:29:18 +0100 Subject: [PATCH] simplify --- src/utils.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 6279a8d..1035bac 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -194,10 +194,9 @@ export function inferPkgExternals(pkg: PackageJson): (string | RegExp)[] { } function pathToRegex(path: string): string | RegExp { - if (!path.includes("*")) { - return path; - } - return new RegExp( - `^${path.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`, - ); + return path.includes("*") + ? new RegExp( + `^${path.replace(/\./g, String.raw`\.`).replace(/\*/g, ".*")}$`, + ) + : path; }