Skip to content

Commit

Permalink
Use executablefinder to run age-keygen
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacastelnuovo committed Jul 3, 2024
1 parent 020c7d5 commit 996c82f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/PrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ public function encode(): string

public function getPublicKey(): PublicKey
{
$result = Process::input($this->encode())->run('age-keygen -y');
/**
* @var array<string>|string|null
*/
$command = [
(new ExecutableFinder())->find('age-keygen', 'age-keygen', [
'/usr/local/bin',
'/opt/homebrew/bin',
]),
'-y',
];

$result = Process::input($this->encode())->run($command);

if ($result->failed()) {
throw new Exception('Failed to generate public key!');
Expand Down

0 comments on commit 996c82f

Please sign in to comment.