-
Notifications
You must be signed in to change notification settings - Fork 58
Closed
Labels
Description
Right now, we exclude some files by default. One file pattern that we don't yet exclude is minified JavaScript files. They usually look like i-am-minified.min.js.
It's not currently possible to exclude files using glob patterns like *.min.js but I think that would be a great addition.
When someone excludes *.min.js, we can turn this into a regex à la .*\.min.js or something, and then exclude the file if it matches that regex. WP_oEmbed::get_provider() has some code that does this. Perhaps we can reuse this.
In the PHP extractor, the relevant code is here:
i18n-command/src/PhpCodeExtractor.php
Lines 129 to 146 in bd16b5f
| /** @var DirectoryIterator $file */ | |
| if ( in_array( $file->getBasename(), $exclude, true ) ) { | |
| return false; | |
| } | |
| // Check for more complex paths, e.g. /some/sub/folder. | |
| foreach( $exclude as $path_or_file ) { | |
| if ( false !== mb_ereg( preg_quote( '/' . $path_or_file ) . '$', $file->getPathname() ) ) { | |
| return false; | |
| } | |
| } | |
| /** @var RecursiveCallbackFilterIterator $iterator */ | |
| if ( $iterator->hasChildren() ) { | |
| return true; | |
| } | |
| return ( $file->isFile() && 'php' === $file->getExtension() ); |
We can probably extend this with a new regex.