From 8aa9061e847d3acae78bbf9a9457bd844fefcddf Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 13 Sep 2016 11:22:18 +1000 Subject: [PATCH] Add in post composer file to add in civicrm custom comment and test if class_exists or not --- composer.json | 6 +++-- tools/scripts/composer/pear-execption-fix.sh | 23 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100755 tools/scripts/composer/pear-execption-fix.sh diff --git a/composer.json b/composer.json index a8e2393485..6ae2d7695e 100644 --- a/composer.json +++ b/composer.json @@ -33,11 +33,13 @@ "scripts": { "post-install-cmd": [ "bash tools/scripts/composer/dompdf-cleanup.sh", - "bash tools/scripts/composer/tcpdf-cleanup.sh" + "bash tools/scripts/composer/tcpdf-cleanup.sh", + "bash tools/scripts/composer/pear-execption-fix.sh" ], "post-update-cmd": [ "bash tools/scripts/composer/dompdf-cleanup.sh", - "bash tools/scripts/composer/tcpdf-cleanup.sh" + "bash tools/scripts/composer/tcpdf-cleanup.sh", + "bash tools/scripts/composer/pear-execption-fix.sh" ] } } diff --git a/tools/scripts/composer/pear-execption-fix.sh b/tools/scripts/composer/pear-execption-fix.sh new file mode 100755 index 0000000000..aa9fca96f5 --- /dev/null +++ b/tools/scripts/composer/pear-execption-fix.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +## Cleanup the vendor tree. The main issue here is that civi Civi is +## deployed as a module inside a CMS, so all its source-code gets published. +## Some libraries distribute admin tools and sample files which should not +## be published. +## +## This script should be idempotent -- if you rerun it several times, it +## should always produce the same post-condition. + +## Replace a line in a file +## This is a bit like 'sed -i', but dumber and more cross-platform. +function simple_replace() { + php -r 'file_put_contents($argv[1], preg_replace($argv[2], $argv[3], file_get_contents($argv[1])));' "$@" +} + + +# add in class_exists test as per CRM-8921. +simple_replace vendor/pear/pear_exception/PEAR/Exception.php '^\<\?php^' '