@@ -57,6 +57,7 @@ protected function configure()
57
57
->addOption ('format ' , null , InputOption::VALUE_REQUIRED , sprintf ('The output format ("%s") ' , implode ('", " ' , $ this ->getAvailableFormatOptions ())))
58
58
->addOption ('show-deprecations ' , null , InputOption::VALUE_NONE , 'Show deprecations as errors ' )
59
59
->addArgument ('filename ' , InputArgument::IS_ARRAY , 'A file, a directory or "-" for reading from STDIN ' )
60
+ ->addOption ('excludes ' , null , InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY , 'Excluded directory ' , [])
60
61
->setHelp (<<<'EOF'
61
62
The <info>%command.name%</info> command lints a template and outputs to STDOUT
62
63
the first encountered syntax error.
@@ -84,6 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
84
85
$ io = new SymfonyStyle ($ input , $ output );
85
86
$ filenames = $ input ->getArgument ('filename ' );
86
87
$ showDeprecations = $ input ->getOption ('show-deprecations ' );
88
+ $ excludes = $ input ->getOption ('excludes ' );
87
89
$ this ->format = $ input ->getOption ('format ' ) ?? (GithubActionReporter::isGithubActionEnvironment () ? 'github ' : 'txt ' );
88
90
89
91
if (['- ' ] === $ filenames ) {
@@ -121,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
121
123
}
122
124
123
125
try {
124
- $ filesInfo = $ this ->getFilesInfo ($ filenames );
126
+ $ filesInfo = $ this ->getFilesInfo ($ filenames, $ excludes );
125
127
} finally {
126
128
if ($ showDeprecations ) {
127
129
restore_error_handler ();
@@ -131,24 +133,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int
131
133
return $ this ->display ($ input , $ output , $ io , $ filesInfo );
132
134
}
133
135
134
- private function getFilesInfo (array $ filenames ): array
136
+ private function getFilesInfo (array $ filenames, array $ excludes ): array
135
137
{
136
138
$ filesInfo = [];
137
139
foreach ($ filenames as $ filename ) {
138
- foreach ($ this ->findFiles ($ filename ) as $ file ) {
140
+ foreach ($ this ->findFiles ($ filename, $ excludes ) as $ file ) {
139
141
$ filesInfo [] = $ this ->validate (file_get_contents ($ file ), $ file );
140
142
}
141
143
}
142
144
143
145
return $ filesInfo ;
144
146
}
145
147
146
- protected function findFiles (string $ filename ): iterable
148
+ protected function findFiles (string $ filename, array $ excludes ): iterable
147
149
{
148
150
if (is_file ($ filename )) {
149
151
return [$ filename ];
150
152
} elseif (is_dir ($ filename )) {
151
- return Finder::create ()->files ()->in ($ filename )->name ($ this ->namePatterns );
153
+ return Finder::create ()->files ()->in ($ filename )->name ($ this ->namePatterns )-> exclude ( $ excludes ) ;
152
154
}
153
155
154
156
throw new RuntimeException (sprintf ('File or directory "%s" is not readable. ' , $ filename ));
0 commit comments