devtools: install npm modules in devtools npm script

If the npm script is run and the node_modules
directory does not exist the script will run
npm install first.

Change-Id: I8db7c6d980dddbbd685cf095652f6112b148c4ba
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/282375
Reviewed-by: Julie Qiu <julie@golang.org>
Trust: Jamal Carvalho <jamal@golang.org>
diff --git a/devtools/npm.sh b/devtools/npm.sh
index 9dda16a..f9fff35 100755
--- a/devtools/npm.sh
+++ b/devtools/npm.sh
@@ -6,6 +6,12 @@
 
 source devtools/lib.sh || { echo "Are you at repo root?"; exit 1; }
 
+# Run npm install if node_modules directory does not exist.
+if [ ! -d "node_modules" ]
+then
+  runcmd docker-compose -f devtools/config/docker-compose.yaml run --rm npm install --quiet
+fi
+
 # Run an npm command and capture the exit code.
 runcmd docker-compose -f devtools/config/docker-compose.yaml run --rm npm $@
 code=$EXIT_CODE