Skip to content

Commit

Permalink
Merge pull request #37 from oallain/fix/console-project-dir
Browse files Browse the repository at this point in the history
fix project dir for console execution
  • Loading branch information
oallain authored May 6, 2021
2 parents 9045a1d + 3c98586 commit c45592b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
public: false
bind:
$logsDir: '%kernel.logs_dir%'
$projectDir: '%kernel.project_dir%'

Synolia\SyliusSchedulerCommandPlugin\:
resource: '../../*'
Expand Down
13 changes: 10 additions & 3 deletions src/Service/ExecuteScheduleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ class ExecuteScheduleCommand
/** @var string */
private $logsDir;

/** @var string */
private $projectDir;

public function __construct(
ScheduledCommandRepository $scheduledCommandRepository,
EntityManagerInterface $entityManager,
KernelInterface $kernel,
string $logsDir
string $logsDir,
string $projectDir
) {
$this->scheduledCommandRepository = $scheduledCommandRepository;
$this->entityManager = $entityManager;
$this->kernel = $kernel;
$this->logsDir = $logsDir;
$this->projectDir = $projectDir;
}

public function executeImmediate(string $commandId): bool
Expand Down Expand Up @@ -91,15 +96,17 @@ private function getLogOutput(ScheduledCommandInterface $scheduledCommand): ?str
private function getCommandLine(ScheduledCommandInterface $scheduledCommand): string
{
$commandLine = sprintf(
'bin/console %s %s',
'%s/bin/console %s %s',
$this->projectDir,
$scheduledCommand->getCommand(),
$scheduledCommand->getArguments() ?? ''
);

$logOutput = $this->getLogOutput($scheduledCommand);
if (null !== $logOutput) {
$commandLine = sprintf(
'bin/console %s %s >> %s 2>> %s',
'%s/bin/console %s %s >> %s 2>> %s',
$this->projectDir,
$scheduledCommand->getCommand(),
$scheduledCommand->getArguments() ?? '',
$logOutput,
Expand Down
3 changes: 0 additions & 3 deletions tests/PHPUnit/Command/SynoliaSchedulerRunCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ public function testExecuteWithANewCommandThatItMarkedAsExecuteNow(): void
self::assertStringNotContainsString('Nothing to do', $commandTester->getDisplay());
}

/**
* @group toto
*/
public function testExecuteNonExistentCommand(): void
{
$invalidCommandName = 'non:existent';
Expand Down

0 comments on commit c45592b

Please sign in to comment.