-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ticket #1157: support specific filenames as trigger for Shell. #1167
base: v2.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
namespace GrumPHP\Task; | ||
|
||
use GrumPHP\Collection\FilesCollection; | ||
use GrumPHP\Exception\RuntimeException; | ||
use GrumPHP\Formatter\ProcessFormatterInterface; | ||
use GrumPHP\Runner\TaskResult; | ||
|
@@ -26,6 +27,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver | |
$resolver->setDefaults([ | ||
'scripts' => [], | ||
'triggered_by' => ['php'], | ||
'triggered_by_filenames' => [], | ||
]); | ||
|
||
$resolver->addAllowedTypes('scripts', ['array']); | ||
|
@@ -59,7 +61,12 @@ public function canRunInContext(ContextInterface $context): bool | |
public function run(ContextInterface $context): TaskResultInterface | ||
{ | ||
$config = $this->getConfig()->getOptions(); | ||
$files = $context->getFiles()->extensions($config['triggered_by']); | ||
$files = new FilesCollection( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $files isn't really being used anywhere. That way we don't have to do all these lookups all of the time. |
||
array_merge( | ||
$context->getFiles()->extensions($config['triggered_by'])->toArray(), | ||
$context->getFiles()->names($config['triggered_by_filenames'])->toArray(), | ||
) | ||
); | ||
if (0 === \count($files)) { | ||
return TaskResult::createSkipped($this, $context); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ public function provideConfigurableOptions(): iterable | |
[ | ||
'scripts' => [], | ||
'triggered_by' => ['php'], | ||
'triggered_by_filenames' => [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll also need a test-case that covers how the task behaves on the newly added configuration. |
||
] | ||
]; | ||
yield 'string_script' => [ | ||
|
@@ -38,6 +39,7 @@ public function provideConfigurableOptions(): iterable | |
['phpunit'] | ||
], | ||
'triggered_by' => ['php'], | ||
'triggered_by_filenames' => [], | ||
] | ||
]; | ||
yield 'array_script' => [ | ||
|
@@ -51,6 +53,7 @@ public function provideConfigurableOptions(): iterable | |
['phpunit', 'tests'] | ||
], | ||
'triggered_by' => ['php'], | ||
'triggered_by_filenames' => [], | ||
] | ||
]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this one is altered? It's not being used anywhere?