aboutsummaryrefslogtreecommitdiff
path: root/all.bash
diff options
context:
space:
mode:
authorJamal Carvalho <jamal@golang.org>2021-05-25 18:48:52 -0400
committerJamal Carvalho <jamal@golang.org>2021-05-25 23:25:54 +0000
commit29fa51cee2ca736e9f2d62ccaea01753e3bbf327 (patch)
tree02a301a6e8151ce8ee55a1fe2754f863d7daf55c /all.bash
parent6a8197aed49ea721495afe59cca80be795cbe95e (diff)
downloadgo-x-pkgsite-29fa51cee2ca736e9f2d62ccaea01753e3bbf327.tar.xz
all.bash,devtools: add support for running npx commands
We will need to run npx commands with docker when running tests in CI. This change creates an npx command in all.bash and modifies the docker_nodejs script to share networking with the host so it can connect to a local instance of the frontend. Change-Id: Id8f32a7ff5bf017cb55c531b1e37a3f8aab0e73a Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/322635 Trust: Jamal Carvalho <jamal@golang.org> Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'all.bash')
-rwxr-xr-xall.bash16
1 files changed, 15 insertions, 1 deletions
diff --git a/all.bash b/all.bash
index 848054cb..8954e311 100755
--- a/all.bash
+++ b/all.bash
@@ -191,6 +191,18 @@ run_npm() {
runcmd $npmcmd $@
}
+run_npx() {
+ npxcmd="./devtools/docker_nodejs.sh npx"
+ if [[ -x "$(command -v npx)" ]]; then
+ npxcmd="npx"
+ fi
+ # Run npm install if node_modules directory does not exist.
+ if [ ! -d "node_modules" ]; then
+ run_npm install --quiet
+ fi
+ runcmd $npxcmd $@
+}
+
prettier_file_globs='content/static/**/*.{ts,css} **/*.md'
# run_prettier runs prettier on CSS, JS, and MD files. Uses globally
@@ -236,7 +248,8 @@ Available subcommands:
headers - (lint) check source files for the license disclaimer
migrations - (lint) check migration sequence numbers
misspell - (lint) run misspell on source files
- npm - run npm scripts from package.json
+ npm - run npm commands or scripts from package.json
+ npx - run a command from a local or remote npm package
script_hashes - (lint) check script hashes
script_output - (lint) check script output
staticcheck - (lint) run staticcheck on source files
@@ -328,6 +341,7 @@ main() {
script_hashes) check_script_hashes ;;
build_static) run_build_static ;;
npm) run_npm ${@:2} ;;
+ npx) run_npx ${@:2} ;;
*)
usage