From 89fcfce9a834258140e370798d258c31ae8a2dbf Mon Sep 17 00:00:00 2001 From: Vidar Langseid Date: Thu, 25 Oct 2018 12:41:15 +0200 Subject: [PATCH] fixup! Fixed so that ezpublish:legacy:init script adds legacy scripts to composer.json --- bundle/Command/LegacyInitCommand.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bundle/Command/LegacyInitCommand.php b/bundle/Command/LegacyInitCommand.php index 16bef6d7..879c6223 100644 --- a/bundle/Command/LegacyInitCommand.php +++ b/bundle/Command/LegacyInitCommand.php @@ -11,6 +11,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Filesystem\Filesystem; class LegacyInitCommand extends ContainerAwareCommand @@ -94,19 +95,20 @@ protected function createDirectories(InputInterface $input, OutputInterface $out protected function updateComposeJson(OutputInterface $output) { + $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; $updateComposerJson = false; $composerJson = json_decode(file_get_contents('composer.json'), true); if ($composerJson === null) { - $output->writeln("Unable to parse composer.json"); + $errOutput->writeln('Error: Unable to parse composer.json'); return; } - if (!array_key_exists('legacy-scripts', $composerJson['scripts'])){ + if (!array_key_exists('legacy-scripts', $composerJson['scripts'])) { $legacy_scripts = [ 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::installAssets', 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::installLegacyBundlesExtensions', 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::generateAutoloads', - 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::symlinkLegacyFiles' + 'eZ\\Bundle\\EzPublishLegacyBundle\\Composer\\ScriptHandler::symlinkLegacyFiles', ]; $composerJson['scripts'] = array_merge(['legacy-scripts' => $legacy_scripts], $composerJson['scripts']); $updateComposerJson = true; @@ -120,7 +122,7 @@ protected function updateComposeJson(OutputInterface $output) $offset = array_search('@php bin/console assetic:dump', $symfonyScripts); if ($offset === false) { - $output->writeln('Warning : Unable to find "assetic:dump" in [symfony-scripts], putting "@legacy_scripts" at the end of array'); + $errOutput->writeln('Warning : Unable to find "assetic:dump" in [symfony-scripts], putting "@legacy_scripts" at the end of array'); $offset = count($symfonyScripts); } @@ -130,7 +132,7 @@ protected function updateComposeJson(OutputInterface $output) } if ($updateComposerJson) { - file_put_contents('composer.json',json_encode($composerJson, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL); + file_put_contents('composer.json', json_encode($composerJson, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL); } } }