From dcf765efda5907887c973cce959120f6b5416d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Fri, 29 Nov 2019 13:43:05 +0100 Subject: [PATCH] Merge pre-install scripts --- package.json | 2 +- scripts/darwin-pre-install.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 scripts/darwin-pre-install.sh diff --git a/package.json b/package.json index 696d26c7..e4e62a55 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "scripts": { "lint:fix": "eslint --fix app.js \"lib/**/*.js\" \"test/**/*.js\"", "lint": "eslint app.js \"lib/**/*.js\" \"test/**/*.js\"", - "preinstall": "./scripts/darwin-pre-install.sh", + "preinstall": "scripts/darwin-pre-install.sh", "pretest:setup": "npm run lint", "test:setup": "NODE_ENV=test node test setup", "pretest": "npm run test:setup", diff --git a/scripts/darwin-pre-install.sh b/scripts/darwin-pre-install.sh new file mode 100755 index 00000000..5cecb996 --- /dev/null +++ b/scripts/darwin-pre-install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [[ "$OSTYPE" == "darwin"* ]]; then + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig + CAIRO_PKG_CONFIG=`pkg-config cairo --cflags-only-I 2> /dev/null` + RESULT=$? + + if [[ ${RESULT} -ne 0 ]]; then + echo "###################################################################################" + echo "# PREINSTALL HOOK ERROR #" + echo "#---------------------------------------------------------------------------------#" + echo "# #" + echo "# node-canvas install error: some packages required by 'cairo' are not found #" + echo "# #" + echo -e "# Use '\033[1mmake all\033[0m', it will take care of common/known issues #" + echo "# #" + echo "# As an alternative try: #" + echo "# Try to 'export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig' #" + echo "# #" + echo "# If problems persist visit: https://github.com/Automattic/node-canvas/wiki #" + echo "# #" + echo "###################################################################################" + exit 1 + fi +fi