From 314b0204bbf26cbe748428ad0bae668ff1bd4595 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 31 Oct 2023 09:30:57 +0100 Subject: [PATCH 1/2] CLI: add option to exclude directories --- includes/CLI/Plugin_Check_Command.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 9319ea17a..6a7be239a 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -87,10 +87,14 @@ public function __construct( Plugin_Context $plugin_context ) { * [--include-experimental] * : Include experimental checks. * + * [--exclude-directories=] + * : Additional directories to exclude from checks + * By default, `.git`, `vendor` and `node_modules` directories are excluded. + * * ## EXAMPLES * * wp plugin check akismet - * wp plugin check akismet --checks=escaping + * wp plugin check akismet --checks=late_escaping * wp plugin check akismet --format=json * * @subcommand check @@ -128,6 +132,15 @@ public function check( $args, $assoc_args ) { // Create the categories array from CLI arguments. $categories = isset( $options['categories'] ) ? wp_parse_list( $options['categories'] ) : array(); + $excluded_directories = isset( $options['exclude-directories'] ) ? wp_parse_list( $options['exclude-directories'] ) : array(); + + add_filter( + 'wp_plugin_check_ignore_directories', + static function ( $dirs ) use ( $excluded_directories ) { + return array_unique( array_merge( $dirs, $excluded_directories ) ); + } + ); + // Get the CLI Runner. $runner = Plugin_Request_Utility::get_runner(); From 5512d52e557a7d89fad5cb176e336cc90021af38 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 31 Oct 2023 11:21:59 +0100 Subject: [PATCH 2/2] Fix check names in docs --- includes/CLI/Plugin_Check_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 6a7be239a..282c422f3 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -60,7 +60,7 @@ public function __construct( Plugin_Context $plugin_context ) { * : The plugin to check. Plugin name. * * [--checks=] - * : Only runs checks provided as an argument in comma-separated values, e.g. enqueued-scripts, escaping. Otherwise runs all checks. + * : Only runs checks provided as an argument in comma-separated values, e.g. i18n_usage, late_escaping. Otherwise runs all checks. * * [--format=] * : Format to display the results. Options are table, csv, and json. The default will be a table.