Skip to content

Commit 0183856

Browse files
committed
Tree command operates on correct directory
1 parent 6d5f03f commit 0183856

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/Commands/TreeCommand.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
namespace Stolt\LeanPackage\Commands;
66

7-
use Stolt\LeanPackage\Exceptions\GitNotAvailable;
8-
use Stolt\LeanPackage\Exceptions\TreeNotAvailable;
9-
use Stolt\LeanPackage\Helpers\Str as OsHelper;
107
use Stolt\LeanPackage\Tree;
118
use Symfony\Component\Console\Command\Command;
129
use Symfony\Component\Console\Input\InputArgument;
@@ -57,21 +54,18 @@ protected function configure(): void
5754

5855
protected function execute(InputInterface $input, OutputInterface $output): int
5956
{
60-
$directory = (string) $input->getArgument('directory');
57+
$this->directoryToOperateOn = (string) $input->getArgument('directory');
6158

62-
if ($directory !== $this->directoryToOperateOn) {
63-
if (!\file_get_contents($directory) || !\is_dir($directory)) {
64-
$warning = "Warning: The provided directory "
65-
. "'$directory' does not exist or is not a directory.";
66-
$outputContent = '<error>' . $warning . '</error>';
67-
$output->writeln($outputContent);
59+
if (!\is_dir($this->directoryToOperateOn)) {
60+
$warning = "Warning: The provided directory "
61+
. "'$this->directoryToOperateOn' does not exist or is not a directory.";
62+
$outputContent = '<error>' . $warning . '</error>';
63+
$output->writeln($outputContent);
6864

69-
return Command::FAILURE;
70-
}
65+
return Command::FAILURE;
7166
}
7267

7368
$showSrcTree = $input->getOption('src');
74-
$showDistPackageTree = $input->getOption('dist-package');
7569

7670
if ($showSrcTree) {
7771
$verboseOutput = '+ Showing flat structure of package source.';
@@ -94,7 +88,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9488

9589
protected function getPackageName(): string
9690
{
97-
$composerContentAsJson = \json_decode(\file_get_contents('composer.json'), true);
91+
$composerContentAsJson = \json_decode(
92+
\file_get_contents($this->directoryToOperateOn . DIRECTORY_SEPARATOR . 'composer.json'),
93+
true
94+
);
9895
return \trim($composerContentAsJson['name']);
9996
}
10097
}

0 commit comments

Comments
 (0)