From b69e4c5fb041f3087328b5a97ebe00b25da22b8d Mon Sep 17 00:00:00 2001 From: Matthieu Napoli <matthieu@mnapoli.fr> Date: Wed, 22 Oct 2014 15:19:32 +1300 Subject: [PATCH] Fixes #6493 Composer install can now run on Windows --- composer.json | 8 ++++---- core/Composer/ScriptHandler.php | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 core/Composer/ScriptHandler.php diff --git a/composer.json b/composer.json index 5608608666..392f934e03 100644 --- a/composer.json +++ b/composer.json @@ -74,16 +74,16 @@ ], "scripts": { "pre-update-cmd": [ - "misc/composer/clean-xhprof.sh" + "Piwik\\Composer\\ScriptHandler::cleanXhprof" ], "pre-install-cmd": [ - "misc/composer/clean-xhprof.sh" + "Piwik\\Composer\\ScriptHandler::cleanXhprof" ], "post-update-cmd": [ - "misc/composer/build-xhprof.sh" + "Piwik\\Composer\\ScriptHandler::buildXhprof" ], "post-install-cmd": [ - "misc/composer/build-xhprof.sh" + "Piwik\\Composer\\ScriptHandler::buildXhprof" ] } } diff --git a/core/Composer/ScriptHandler.php b/core/Composer/ScriptHandler.php new file mode 100644 index 0000000000..d4db6536b0 --- /dev/null +++ b/core/Composer/ScriptHandler.php @@ -0,0 +1,36 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Composer; + +/** + * Scripts executed before/after Composer install and update. + * + * We use this PHP class because setting the bash scripts directly in composer.json breaks + * Composer on Windows systems. + */ +class ScriptHandler +{ + public static function cleanXhprof() + { + if (! is_dir('vendor/facebook/xhprof/extension')) { + return; + } + + passthru('misc/composer/clean-xhprof.sh'); + } + + public static function buildXhprof() + { + if (! is_dir('vendor/facebook/xhprof/extension')) { + return; + } + + passthru('misc/composer/build-xhprof.sh'); + } +} -- GitLab