From 951fd7c1462010d8c17d76bdd1463c0edd3ce95e Mon Sep 17 00:00:00 2001 From: lpeidro Date: Wed, 23 Oct 2024 12:18:16 +0200 Subject: [PATCH] Added possiblity to overrite the destination --- README.md | 11 +++++++++++ src/InstallerPlugin.php | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c6170dd..f31d371 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,14 @@ A library that extends and improves the default options provided by [BackstopJS] ### Composer ``composer require --dev metadrop/backstopjs-addons`` + +You can override the default destination of the library by adding the following parameter to the extra section +of your project's composer.json file: + +```json +"extra": { + "backstop-addons": { + "destinition": "custom/destinition" + } +``` + \ No newline at end of file diff --git a/src/InstallerPlugin.php b/src/InstallerPlugin.php index 3bb8ef8..fe5ccce 100644 --- a/src/InstallerPlugin.php +++ b/src/InstallerPlugin.php @@ -47,9 +47,16 @@ public static function getSubscribedEvents() public function MoveFiles(Event $event) { $composer = $event->getComposer(); + // Source $source = $composer->getConfig()->get('vendor-dir') . '/metadrop/backstopjs-addons/addons'; + + // Destination $root = $composer->getConfig()->get('vendor-dir') . '/..'; - $destination = $root . '/tests/backstopjs/common/libraries/backstopjs-addons'; + + $extra = $composer->getPackage()->getExtra(); + $backstop_addons_extras = $extra['backstop-addons'] ?? []; + $destination = $backstop_addons_extras['destination'] ?? 'tests/backstopjs/common/libraries/backstopjs-addons'; + $destination = "{$root}/{$destination}"; if (is_dir($destination)) { self::deleteDirectoryContents($destination);