Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/Concerns/ConfiguresForLintOrFix.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ protected function configure(): void
mode: InputOption::VALUE_REQUIRED,
description: 'Only fix files that have changed since branching off from the given branch',
),
new InputOption(
name: 'exclude',
mode: InputOption::VALUE_REQUIRED,
description: 'Exclude paths (comma separated)',
),
]
);
}
Expand Down
3 changes: 2 additions & 1 deletion app/Providers/DusterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ public function register(): void
};

$dusterConfig = DusterConfig::loadLocal();
$excludeFromCli = array_filter(explode(',', (string) $input->getOption('exclude')));

return new DusterConfig([
'paths' => Project::paths($input),
'using' => $input->getOption('using'),
'mode' => $mode,
'include' => $dusterConfig['include'] ?? [],
'exclude' => $dusterConfig['exclude'] ?? [],
'exclude' => array_merge($dusterConfig['exclude'] ?? [], $excludeFromCli),
'scripts' => $dusterConfig['scripts'] ?? [],
]);
});
Expand Down
4 changes: 2 additions & 2 deletions app/Providers/PintServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function register(): void
base_path('standards/pint.json'),
])->first(fn ($path) => file_exists($path));

$dusterConfig = DusterConfig::scopeConfigPaths(DusterConfig::loadLocal());
$dusterConfig = resolve(DusterConfig::class);

return new PintConfigurationJsonRepository($config, null, $dusterConfig['exclude']);
return new PintConfigurationJsonRepository($config, null, $dusterConfig->get('exclude', []));
});

$this->app->singleton(PathsRepository::class, fn () => new GitPathsRepository(
Expand Down
12 changes: 12 additions & 0 deletions tests/Feature/LintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@
->not->toContain('Linting using PHP CS Fixer');
});

it('excludes paths passed via --exclude option', function () {
[$statusCode, $output] = run('lint', [
'path' => base_path('tests'),
'--exclude' => 'Fixtures/PintFixableIssues',
'--using' => 'pint',
]);

expect($output)
->toContain('Linting using Pint')
->not->toContain('PintFixableIssues');
});

it('lints multiple provided files', function () {
[$statusCode, $output] = run('lint', [
'path' => [
Expand Down