-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathMyTestCommand.php
63 lines (50 loc) · 1.5 KB
/
MyTestCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
namespace Bamarni\Composer\Bin\Tests\Fixtures;
use Composer\Composer;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Command\BaseCommand;
use Composer\Factory;
use Composer\IO\NullIO;
use function method_exists;
class MyTestCommand extends BaseCommand
{
/**
* @var mixed|Composer
*/
public $composer;
/**
* @var list<array{'bin-dir': string, 'cwd': string, 'vendor-dir': string}>
*/
public $data = [];
public function __construct()
{
parent::__construct('mytest');
$this->setDefinition([
new InputOption(
'myoption',
null,
InputOption::VALUE_NONE
),
]);
}
public function execute(InputInterface $input, OutputInterface $output): int
{
// Switch to tryComposer() once Composer 2.3 is set as the minimum
$this->composer = method_exists($this, 'tryComposer')
? $this->tryComposer()
: $this->getComposer(false);
$factory = Factory::create(new NullIO());
$config = $factory->getConfig();
$this->data[] = [
'bin-dir' => $config->get('bin-dir'),
'cwd' => getcwd(),
'vendor-dir' => $config->get('vendor-dir'),
];
$this->resetComposer();
$this->getApplication()->resetComposer();
return 0;
}
}