Skip to content

Commit

Permalink
puppeteer: bootstrap at least node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed May 29, 2023
1 parent 25fe285 commit ce33915
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion script/install_puppeteer.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash
#
# usage: ./install_puppeteer.sh
#
# installs puppeteer into /var/lib/thruk/puppeteer so it can be used to render PDFs
#

DEST=$1
if [ -z "$DEST" ]; then
Expand All @@ -16,7 +21,23 @@ cd $DEST
export PUPPETEER_DOWNLOAD_PATH=$DEST/chromium
echo "module.exports = {}" > .puppeteerrc.cjs
mkdir -p node_modules
npm i progress puppeteer

# check node version, must be at least 16
NODE_VERSION=$(node -v 2>/dev/null | sed -e 's/^v//' -e 's/\..*$//g')
if [ -z $NODE_VERSION ]; then
echo "failed to detect node version"
exit 1
fi

NPM="npm"
if [ $NODE_VERSION -lt 16 ]; then
npm i n
export N_PREFIX=$(pwd)/node
./node_modules/.bin/n 16
NPM="./node_modules/.bin/n exec 16 npm"
fi

$NPM i progress puppeteer
set +e

if [ -n "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" ]; then
Expand Down

0 comments on commit ce33915

Please sign in to comment.