Skip to content

Commit

Permalink
refactor(pnpm): strip special characters from pkg labels
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jun 27, 2024
1 parent ae87a9b commit 3c8c881
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 58 deletions.
5 changes: 2 additions & 3 deletions npm/private/pnpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ def _convert_pnpm_v6_v9_version_peer_dep(version):
# Prevent long paths. The pnpm lockfile v6 no longer hashes long sequences of
# peer deps so we must hash here to prevent extremely long file paths that lead to
# "File name too long) build failures.
peer_dep = "_" + utils.hash(peer_dep)
version = version[0:peer_dep_index] + utils.sanitize_string(peer_dep)
version = version.rstrip("_")
peer_dep = utils.hash(peer_dep)
version = version[0:peer_dep_index] + "_" + utils.sanitize_string(peer_dep)
return version

def _strip_v6_default_registry_to_version(name, version):
Expand Down
10 changes: 5 additions & 5 deletions npm/private/test/snapshots/bzlmod/npm_defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions npm/private/test/snapshots/wksp/npm_defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 44 additions & 44 deletions npm/private/test/snapshots/wksp/repositories.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion npm/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _sanitize_string(string):
if not c.isalnum() and c != "-" and c != "_" and c != ".":
c = "_"
result += c
return result
return result.strip("_-")

def _bazel_name(name, version = None):
"Make a bazel friendly name from a package name and (optionally) a version that can be used in repository and target names"
Expand Down

0 comments on commit 3c8c881

Please sign in to comment.