Skip to content

Commit

Permalink
improved tree colors
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed May 19, 2017
1 parent 3ddd313 commit 37dcf77
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,31 +408,18 @@ protected function showDepsTree()
return;
}

$this->initStyles();
foreach (array_reverse($this->orderedList) as $name => $depth) {
$deps = $this->originalFiles[$name];
$color = $this->colors[$depth];
$color = $this->colors[$depth % count($this->colors)];
$indent = str_repeat(' ', $depth - 1);
$package = $this->plainList[$name];
$showdeps = $deps ? '[' . implode(',', array_keys($deps)) . ']' : '';
$this->io->write(sprintf('%s - <%s>%s</%s> %s %s', $indent, $color, $name, $color, $package->getFullPrettyVersion(), $showdeps));
$showdeps = $deps ? '<comment>[' . implode(',', array_keys($deps)) . ']</>' : '';
$this->io->write(sprintf('%s - <fg=%s;options=bold>%s</> %s %s', $indent, $color, $name, $package->getFullPrettyVersion(), $showdeps));
}
}

protected $colors = ['red', 'green', 'yellow', 'cyan', 'magenta', 'blue'];

protected function initStyles()
{
$ref = new \ReflectionProperty(get_class($this->io), 'output');
$ref->setAccessible(true);
$output = $ref->getValue($this->io);

foreach ($this->colors as $color) {
$style = new OutputFormatterStyle($color);
$output->getFormatter()->setStyle($color, $style);
}
}

/**
* Get absolute path to package base dir.
* @return string
Expand Down

0 comments on commit 37dcf77

Please sign in to comment.