Skip to content

Commit

Permalink
Merge pull request #9 from castelnuovo/path-pubkey-generation
Browse files Browse the repository at this point in the history
Use executablefinder to run age-keygen
  • Loading branch information
lucacastelnuovo authored Jul 3, 2024
2 parents 020c7d5 + 996c82f commit 5b2e3dd
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 5b2e3dd

Please sign in to comment.