From 62e435fd9ec9fcb9f42aa9f9b63daa6cc4404f46 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Mon, 23 Feb 2015 12:08:08 +0100 Subject: [PATCH] Improve installation feedback as we did in Windshaft --- Makefile | 21 +++++---------------- package.json | 3 ++- scripts/check-node-canvas.sh | 24 ++++++++++++++++++++++++ scripts/install.sh | 7 +++++++ 4 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 scripts/check-node-canvas.sh create mode 100644 scripts/install.sh diff --git a/Makefile b/Makefile index 32a48859..c6b2cf62 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ -srcdir=$(shell pwd) - all: - npm install + @sh ./scripts/install.sh clean: rm -rf node_modules/* @@ -15,7 +13,8 @@ config.status--test: config/environments/test.js: config.status--test ./config.status--test -check-local: config/environments/test.js +test: config/environments/test.js + @echo "***tests***" ./run_tests.sh ${RUNTESTFLAGS} \ test/unit/cartodb/*.js \ test/unit/cartodb/cache/model/*.js \ @@ -23,16 +22,6 @@ check-local: config/environments/test.js test/acceptance/*.js \ test/acceptance/cache/*.js -check-submodules: - PATH="$$PATH:$(srcdir)/node_modules/.bin/"; \ - for sub in windshaft grainstore node-varnish mapnik; do \ - if test -e node_modules/$${sub}; then \ - echo "Testing submodule $${sub}"; \ - make -C node_modules/$${sub} check || exit 1; \ - fi; \ - done - -check-full: check-local check-submodules - -check: check-local +check: test +.PHONY: test diff --git a/package.json b/package.json index b6ebb47b..1b0219bf 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "semver": "~1.1.4" }, "scripts": { - "test": "make check" + "preinstall": "sh ./scripts/check-node-canvas.sh", + "test": "make test" }, "engines": { "node": ">=0.8 <0.11", diff --git a/scripts/check-node-canvas.sh b/scripts/check-node-canvas.sh new file mode 100644 index 00000000..b5fa8f30 --- /dev/null +++ b/scripts/check-node-canvas.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +if [[ "$OSTYPE" == "darwin"* ]]; then + 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 "# 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 diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 00000000..1817644c --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +if [[ "$OSTYPE" == "darwin"* ]]; then + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig +fi + +npm install