From 9763f20e4b7bb1091082462b2f7970e965d0d414 Mon Sep 17 00:00:00 2001 From: David Supplee Date: Tue, 22 Jun 2021 14:01:30 -0700 Subject: [PATCH] build: enable npm for php/python builds (#1133) * build: enable npm for php/python builds * update comment --- .kokoro-autosynth/build-in-docker.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.kokoro-autosynth/build-in-docker.sh b/.kokoro-autosynth/build-in-docker.sh index 5e1546f3c..8122f98b1 100755 --- a/.kokoro-autosynth/build-in-docker.sh +++ b/.kokoro-autosynth/build-in-docker.sh @@ -28,6 +28,23 @@ ssh-keyscan github.com >> "$HOME/.ssh/known_hosts" # Kokoro exposes this as a file, but the scripts expect just a plain variable. export GITHUB_TOKEN=$(cat ${KOKORO_KEYSTORE_DIR}/73713_yoshi-automation-github-key) +# Install npm to facilitate installation of a code formatter for PHP: https://github.com/prettier/plugin-php +# Use `nvm` to bootstrap the installation of node.js and npm. +# To learn more: https://github.com/nvm-sh/nvm +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash + +# Activate `nvm` so the binary is available on the path +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +# Use the latest LTS version of nodejs. This can change over time, but +# should prevent the need to modify this file every year. +nvm install --lts + +# Verify expected versions of nodejs and npm +node --version +npm --version + # Setup git credentials echo "https://${GITHUB_TOKEN}:@github.com" >> ~/.git-credentials git config --global credential.helper 'store --file ~/.git-credentials'