-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: switch to using an executable object to interact with composer
- Loading branch information
1 parent
77b2ec3
commit 9f1940a
Showing
3 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Ymir command-line tool. | ||
* | ||
* (c) Carl Alexander <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Ymir\Cli\Executable; | ||
|
||
class ComposerExecutable extends AbstractExecutable | ||
{ | ||
/** | ||
* Create a new project from the given package into the given directory. | ||
*/ | ||
public function createProject(string $package, string $directory = '.') | ||
{ | ||
$this->run(sprintf('create-project %s %s', $package, $directory)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDisplayName(): string | ||
{ | ||
return 'Composer'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getExecutable(): string | ||
{ | ||
return 'composer'; | ||
} | ||
|
||
/** | ||
* Add the given package to the project's "composer.json" file and install it. | ||
*/ | ||
public function require(string $package) | ||
{ | ||
$this->run(sprintf('require %s', $package)); | ||
} | ||
} |