[Scoper] Skip vendor/composer/composer for prefixing (#6291)

* [Scoper] Skip vendor/composer/composer for prefixing

* on Composer\Plugin
This commit is contained in:
Abdul Malik Ikhsan 2021-05-02 23:41:19 +07:00 committed by GitHub
parent f9170bec35
commit e7dba6f48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -39,6 +39,7 @@ jobs:
# 1. (a) copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
- run: rsync --exclude rector-build-php70 -av * rector-build-php70 --quiet
- run: rm -rf rector-build-php70/packages-tests rector-build-php70/rules-tests rector-build-php70/tests
# 2. downgrade rector
- run: sh build/downgrade-rector-php70.sh rector-build-php70
@ -46,9 +47,6 @@ jobs:
# 3. prefix classes
- run: sh build/build-rector-scoped.sh rector-build-php70 rector-prefixed-downgraded-php70
# 1. (b) remove tests directory after run scoped
- run: rm -rf rector-build-php70/packages-tests rector-build-php70/rules-tests rector-build-php70/tests
# 4. lint the code for PHP 7.0 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
-
uses: shivammathur/setup-php@v2

View File

@ -69,6 +69,18 @@ return [
);
},
function (string $filePath, string $prefix, string $content): string {
if (! Strings::contains($content, $prefix . '\Composer\Plugin')) {
return $content;
}
return Strings::replace(
$content, '
#' . $prefix . '\\\\Composer\\\\Plugin#',
'Composer\Plugin'
);
},
// get version for prefixed version
function (string $filePath, string $prefix, string $content): string {
if (! Strings::endsWith($filePath, 'src/Configuration/Configuration.php')) {