Skip to content

Commit 43792a8

Browse files
committed
Fixes issue where no package name is set
1 parent d4d7d6e commit 43792a8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Commands/TreeCommand.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9696

9797
protected function getPackageName(): string
9898
{
99-
if (!\file_exists($this->directoryToOperateOn . DIRECTORY_SEPARATOR . 'composer.json')) {
99+
if (!\file_exists(WORKING_DIRECTORY . DIRECTORY_SEPARATOR . $this->directoryToOperateOn . DIRECTORY_SEPARATOR . 'composer.json')) {
100100
return 'unknown/unknown';
101101
}
102102

103103
$composerContentAsJson = \json_decode(
104-
\file_get_contents($this->directoryToOperateOn . DIRECTORY_SEPARATOR . 'composer.json'),
104+
\file_get_contents(WORKING_DIRECTORY . DIRECTORY_SEPARATOR . $this->directoryToOperateOn . DIRECTORY_SEPARATOR . 'composer.json'),
105105
true
106106
);
107+
108+
if (!isset($composerContentAsJson['name'])) {
109+
return 'unknown/unknown';
110+
}
111+
107112
return \trim($composerContentAsJson['name']);
108113
}
109114
}

0 commit comments

Comments
 (0)