From 3b2bc03f51232ad46fa69234d9adbdbb7951a1e5 Mon Sep 17 00:00:00 2001 From: Ian Lewis Date: Tue, 11 Jul 2023 03:56:31 +0900 Subject: [PATCH] fix: non-scoped package handling (#2367) Fixes #2359 Fixes parsing of npm package names when non-scoped. Signed-off-by: Ian Lewis Signed-off-by: Noah Elzner --- internal/builders/nodejs/generate-layout.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/builders/nodejs/generate-layout.sh b/internal/builders/nodejs/generate-layout.sh index 55b1edb185..7ff8ccf3ae 100755 --- a/internal/builders/nodejs/generate-layout.sh +++ b/internal/builders/nodejs/generate-layout.sh @@ -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 '/' -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.