summaryrefslogtreecommitdiff
path: root/run.sh
diff options
context:
space:
mode:
authorBrian Wald <bwald@gitlab.com>2019-02-09 13:11:34 +0000
committerPhilippe Lafoucrière <plafoucriere@gitlab.com>2019-02-09 13:11:34 +0000
commit17f837eee765afa68af155da43a84322dcb91284 (patch)
tree47f7078db04f3f53cf6158d59f29f3c472176b71 /run.sh
parentf21e2f545ea81cda9d6691d87000e247189b9dbf (diff)
Resolve NPM failures with certain Optional or Peer dependencies
Diffstat (limited to 'run.sh')
-rwxr-xr-xrun.sh40
1 files changed, 29 insertions, 11 deletions
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