-
-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make file processor always return string, handle diff outside
- Loading branch information
1 parent
9c1cdae
commit 5364e4b
Showing
8 changed files
with
76 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
rules/Composer/ErrorReporting/ComposerJsonChangeReporter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Composer\ErrorReporting; | ||
|
||
use Rector\Core\Configuration\Configuration; | ||
use Symfony\Component\Process\Process; | ||
use Symplify\ComposerJsonManipulator\Printer\ComposerJsonPrinter; | ||
use Symplify\ComposerJsonManipulator\ValueObject\ComposerJson; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class ComposerJsonChangeReporter | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private const COMPOSER_UPDATE = 'composer update'; | ||
|
||
/** | ||
* @var Configuration | ||
*/ | ||
private $configuration; | ||
|
||
/** | ||
* @var ComposerJsonPrinter | ||
*/ | ||
private $composerJsonPrinter; | ||
|
||
public function __construct(Configuration $configuration, ComposerJsonPrinter $composerJsonPrinter) | ||
{ | ||
$this->configuration = $configuration; | ||
$this->composerJsonPrinter = $composerJsonPrinter; | ||
} | ||
|
||
public function reportFileContentChange(ComposerJson $composerJson, SmartFileInfo $smartFileInfo): void | ||
{ | ||
if ($this->configuration->isDryRun()) { | ||
return; | ||
} | ||
|
||
$this->composerJsonPrinter->print($composerJson, $smartFileInfo); | ||
|
||
$process = new Process(explode(' ', self::COMPOSER_UPDATE), getcwd()); | ||
$process->run(function (string $type, string $message): void { | ||
// $type is always err https://github.com/composer/composer/issues/3795#issuecomment-76401013 | ||
echo $message; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters