diff --git a/nodejs-packaging-bundler b/nodejs-packaging-bundler index 0dd61d7..8a1f83c 100755 --- a/nodejs-packaging-bundler +++ b/nodejs-packaging-bundler @@ -41,7 +41,8 @@ if [ $# -ge 2 ]; then else VERSION="$(npm view ${PACKAGE} version)" fi - +# the package name might contain invalid characters, sanitize first +PACKAGE_SAFE=$(echo $PACKAGE | sed -e 's|/|-|g') TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX) mkdir -p ${OUTPUT_DIR} mkdir -p ${TMP_DIR} @@ -59,10 +60,10 @@ else mv node_modules/ node_modules_prod fi echo "LICENSES IN BUNDLE:" -find . -name "package.json" -exec jq .license {} \; >> ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt -find . -name "package.json" -exec jq '.licenses[] .type' {} \; >> ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt 2>/dev/null -sed -i "/^null$/d" ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt -sort -u -o ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt ${TMP_DIR}/${PACKAGE}-${VERSION}-bundled-licenses.txt +find . -name "package.json" -exec jq .license {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt +find . -name "package.json" -exec jq '.licenses[] .type' {} \; >> ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt 2>/dev/null +sed -i "/^null$/d" ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt +sort -u -o ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt ${TMP_DIR}/${PACKAGE_SAFE}-${VERSION}-bundled-licenses.txt echo " Downloading dev dependencies" npm install --no-optional --only=dev if [ $? -ge 1 ] ; then @@ -72,12 +73,12 @@ else mv node_modules/ node_modules_dev fi if [ -d node_modules_prod ] ; then - tar cfz ../${PACKAGE}-${VERSION}-nm-prod.tgz node_modules_prod + tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-prod.tgz node_modules_prod fi if [ -d node_modules_dev ] ; then - tar cfz ../${PACKAGE}-${VERSION}-nm-dev.tgz node_modules_dev + tar cfz ../${PACKAGE_SAFE}-${VERSION}-nm-dev.tgz node_modules_dev fi cd .. -cp -v ${PACKAGE}-${VERSION}* $HOME/rpmbuild/SOURCES +cp -v ${PACKAGE_SAFE}-${VERSION}* $HOME/rpmbuild/SOURCES popd > /dev/null rm -rf ${TMP_DIR}