diff --git a/.github/bump-version.get.sh b/.github/bump-version.get.sh index aa16c71..5f24c47 100755 --- a/.github/bump-version.get.sh +++ b/.github/bump-version.get.sh @@ -43,9 +43,12 @@ for FILE in ${VERSFILES} ; do VERS=$(grep "const Version" < "${FILE}" | sed -e 's/^[^"]*"//' -e 's/"$//') ;; package.json) - # get the root package's name. - ROOTJSNAME="$(jq -re '.name' < package.json)" - if [ "$(dirname "${FILE}")" = "." ] || ! VERS=$(jq -re ".dependencies[\"${ROOTJSNAME}\"]" < "${FILE}") ; then + # get the root package's name, if there is a root package.json. + ROOTJSNAME="" + if [ -f package.json ] ; then + ROOTJSNAME="$(jq -re '.name' < package.json)" + fi + if [ "$(dirname "${FILE}")" = "." ] || [ -z "${ROOTJSNAME}" ] || ! VERS=$(jq -re ".dependencies[\"${ROOTJSNAME}\"]" < "${FILE}") ; then # This is the root package.json, so we want .version OR # This isn't directly dependant on the root package.json, so we assume we're in a monorepo (ie CB yarn workspaces). VERS=$(jq -re '.version' < "${FILE}") diff --git a/.github/bump-version.set.sh b/.github/bump-version.set.sh index 74ec908..6bab235 100755 --- a/.github/bump-version.set.sh +++ b/.github/bump-version.set.sh @@ -59,9 +59,12 @@ for FILE in ${VERSFILES} ; do ;; package.json) - # Get the root package's name. - ROOTJSNAME="$(jq -re '.name' < package.json)" - if [ "${DIR}" = "." ] || ! jq -re ".dependencies[\"${ROOTJSNAME}\"]" < "${FILE}" ; then + # Get the root package's name, if there is a root package.json. + ROOTJSNAME="" + if [ -f package.json ] ; then + ROOTJSNAME="$(jq -re '.name' < package.json)" + fi + if [ "${DIR}" = "." ] || [ -z "${ROOTJSNAME}" ] || ! jq -re ".dependencies[\"${ROOTJSNAME}\"]" < "${FILE}" ; then # This is the root package.json, or we're assuming we're in a monorepo because we aren't dependant on the # root, so we want .version. jq --indent 4 ".version=\"${NEWVERS}\"" "${FILE}" > "${FILE}.new"