xref: /openbmc/webui-vue/format-code.sh (revision 511650a9)
1#!/bin/bash
2# Run GUI Linting and Formatting as part of the CI Build process
3#
4# This is a short term solution. The long term solution to will be to
5# add much of this to the build script.
6#
7
8set -e
9
10# When called from openbmc-build-scripts, the `pwd` could be anywhere, but
11# the root of the repo is passed in the first argument.  Switch to the repo
12# root so npm/git run in the right place.
13if [ -n "$1" ]; then
14    cd "$1"
15fi
16
17npm install
18npm run lint
19
20# CI might be running a different version of NPM than yocto, and we don't
21# want to trigger a formatting failure if package-lock.json has changed
22# Therefore, revert it back to what it was previously.
23git checkout package-lock.json
24git --no-pager diff --exit-code
25