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);