summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--Dockerfile6
-rwxr-xr-xrun.sh40
3 files changed, 36 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f793b6..c52cb32 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# GitLab License management changelog
+## 1.2.1
+
+- Better support for js npm projects (!14)
+
## 1.2.0
- Bump LicenseFinder to 5.5.2
diff --git a/Dockerfile b/Dockerfile
index 7c7c38c..c2f6c33 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,10 +6,10 @@ RUN npm install npm-install-peers cheerio
# Don't let Rubygem fail with the numerous projects using PG or MySQL, install realpath
RUN apt-get update && apt-get install -y libpq-dev libmysqlclient-dev realpath && rm -rf /var/lib/apt/lists/*
-COPY run.sh html2json.js /
-COPY test /test
-
# Don't load RVM automatically, it doesn't work with GitLab-CI
RUN mv /etc/profile.d/rvm.sh /rvm.sh
+COPY test /test
+COPY run.sh html2json.js /
+
ENTRYPOINT ["/run.sh"]
diff --git a/run.sh b/run.sh
index bba4771..45fb3ab 100755
--- a/run.sh
+++ b/run.sh
@@ -81,7 +81,7 @@ case "$COMMAND" in
# Change current directory to the project path.
APP_PATH=$1
shift
- pushd $APP_PATH
+ pushd $APP_PATH > /dev/null
if [[ -z "${SETUP_CMD}" ]]; then
# Before running license_finder, we need to install dependencies for the project.
@@ -108,11 +108,27 @@ case "$COMMAND" in
pip install -r requirements.txt
fi
- if test -f package.json ; then
- # Install NPM packages.
- npm install --production
- # Try to install Peer packages too, npm install doesn't do it anymore.
- /node_modules/.bin/npm-install-peers
+ if test -f package.json; then
+ # Check is npm is being used, if so convert it to yarn
+ if [ -f package-lock.json ] && [ ! -f yarn.lock ] ; then
+ # restore original lock file state on EXIT
+ function restore_lockfile {
+ echo "Cleanup generated $APP_PATH/yarn.lock"
+ rm -f $APP_PATH/yarn.lock || true
+ }
+ trap restore_lockfile EXIT
+
+ echo "Convert package-lock.json to yarn.lock"
+ yarn import
+ fi
+
+ # install via yarn
+ if [ ! -d node_modules ]; then
+ yarn install --ignore-scripts
+
+ # Try to install Peer packages too, npm install doesn't do it anymore.
+ /node_modules/.bin/npm-install-peers
+ fi
fi
if test -f bower.json ; then
@@ -125,14 +141,14 @@ case "$COMMAND" in
if test -f Godeps/Godeps.json ; then
# Install Go dependencies with Godeps.
- pushd /gopath/src/app
+ pushd /gopath/src/app > /dev/null
godep restore
- popd
+ popd > /dev/null
elif find . -name "*.go" -printf "found" -quit |grep found >/dev/null ; then
# Install Go dependencies with go get.
- pushd /gopath/src/app
+ pushd /gopath/src/app > /dev/null
go get
- popd
+ popd > /dev/null
fi
if test -f pom.xml ; then
@@ -151,7 +167,9 @@ case "$COMMAND" in
# Run License Finder.
echo "Running license_finder $@ in $PWD"
license_finder report --format=html --save=gl-license-management-report.html
- popd
+ # rvm removes trap in bash: https://github.com/rvm/rvm/issues/4416
+ declare -f restore_lockfile > /dev/null && restore_lockfile
+ popd > /dev/null
# Extract data from the HTML report and put it into a JSON file
node /html2json.js $APP_PATH/gl-license-management-report.html > $APP_PATH/gl-license-management-report.json