xref: /openbmc/webui-vue/format-code.sh (revision 02e1497349377af132d987bad9980299af45201b)
191f8ad36SPatrick Williams#!/bin/bash
2bf2131f8SDerick Montague# Run GUI Linting and Formatting as part of the CI Build process
3bf2131f8SDerick Montague#
4bf2131f8SDerick Montague# This is a short term solution. The long term solution to will be to
5bf2131f8SDerick Montague# add much of this to the build script.
6bf2131f8SDerick Montague#
7bf2131f8SDerick Montague
8bf2131f8SDerick Montagueset -e
9bf2131f8SDerick Montague
1091f8ad36SPatrick Williams# When called from openbmc-build-scripts, the `pwd` could be anywhere, but
1191f8ad36SPatrick Williams# the root of the repo is passed in the first argument.  Switch to the repo
1291f8ad36SPatrick Williams# root so npm/git run in the right place.
1391f8ad36SPatrick Williamsif [ -n "$1" ]; then
1491f8ad36SPatrick Williams    cd "$1"
1591f8ad36SPatrick Williamsfi
1691f8ad36SPatrick Williams
17*02e14973SEd Tanousnpm install
18bf2131f8SDerick Montaguenpm run lint
19*02e14973SEd Tanous
20*02e14973SEd Tanous# CI might be running a different version of NPM than yocto, and we don't
21*02e14973SEd Tanous# want to trigger a formatting failure if package-lock.json has changed
22*02e14973SEd Tanous# Therefore, revert it back to what it was previously.
23*02e14973SEd Tanousgit checkout package-lock.json
24bf2131f8SDerick Montaguegit --no-pager diff --exit-code
25