Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 27, 2024
1 parent c9bf5aa commit a12275b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit a12275b

Please sign in to comment.