Skip to content

Commit

Permalink
fix: non-scoped package handling (#2367)
Browse files Browse the repository at this point in the history
Fixes #2359 

Fixes parsing of npm package names when non-scoped.

Signed-off-by: Ian Lewis <ianlewis@google.com>
  • Loading branch information
Ian Lewis authored Jul 10, 2023
1 parent ffbc1e5 commit 391661a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/builders/nodejs/generate-layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ set -euo pipefail

# Get the raw package name and scope from the output of `npm pack --json`
# This name is of the form '<scope>/<package name>'
raw_package_scope=$(echo "${PACKAGE_NAME:-}" | cut -d'/' -f1)
raw_package_name=$(echo "${PACKAGE_NAME:-}" | cut -d'/' -f2)
# NOTE: `cut -s` will suppress output for all fields if the delimiter is
# not present.
raw_package_scope=$(echo "${PACKAGE_NAME:-}" | cut -s -d'/' -f1)
raw_package_name=$(echo "${PACKAGE_NAME:-}" | cut -s -d'/' -f2)
if [ "${raw_package_name}" == "" ]; then
raw_package_name="${raw_package_scope}"
# This is a non-scoped package.
raw_package_name="${PACKAGE_NAME:-}"
raw_package_scope=""
fi
# package scope (namespace) is URL(percent) encoded.
Expand Down

0 comments on commit 391661a

Please sign in to comment.