Skip to content

Commit

Permalink
Merge pull request #275 from orchestral/7/vendor-publish-command
Browse files Browse the repository at this point in the history
* [7.x] Override `vendor:publish` command for Testbench CLI

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone authored Dec 11, 2024
2 parents cb3e56a + f7d000e commit 72b4423
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Concerns/InteractsWithTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait InteractsWithTestCase
/**
* The method attributes for test case.
*
* @var array<int, array{key: class-string, instance: object}>
* @var array<int, array{key: class-string, instance: object}>
*
* @phpstan-var array<int, array{key: class-string<TTestingFeature>, instance: TTestingFeature}>
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Foundation/Console/Actions/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ protected function pathLocation(string $path): string
return implode('/', [$prefix, ltrim($path, '/')]);
}


if (str_starts_with($path, $packagePath)) {
return sprintf('./%s', ltrim(str_replace($packagePath, '', $path), '/'));
return \sprintf('./%s', ltrim(str_replace($packagePath, '', $path), '/'));
}

return $path;
Expand Down
29 changes: 29 additions & 0 deletions src/Foundation/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Orchestra\Testbench\Foundation\Console;

use Illuminate\Foundation\Console\VendorPublishCommand as Command;

use function Orchestra\Testbench\package_path;

/**
* @codeCoverageIgnore
*/
class VendorPublishCommand extends Command
{
/** {@inheritDoc} */
#[\Override]
protected function status($from, $to, $type)
{
$from = str_replace(package_path().'/', '', (string) realpath($from));

$to = str_replace(base_path().'/', '', (string) realpath($to));

$this->components->task(\sprintf(
'Copying %s [%s] to [%s]',
$type,
$from,
$to,
));
}
}
1 change: 1 addition & 0 deletions src/Foundation/TestbenchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function boot()
Console\PurgeSkeletonCommand::class,
Console\SyncSkeletonCommand::class,
Console\ServeCommand::class,
Console\VendorPublishCommand::class,
]);
}
}
Expand Down

0 comments on commit 72b4423

Please sign in to comment.