Skip to content

Commit

Permalink
Added possiblity to overrite the destination
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeidro committed Oct 23, 2024
1 parent f5762c1 commit 951fd7c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
```

9 changes: 8 additions & 1 deletion src/InstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 951fd7c

Please sign in to comment.