Skip to content

Commit

Permalink
fix: gpg key import errors
Browse files Browse the repository at this point in the history
  • Loading branch information
virtual-designer committed Aug 28, 2024
1 parent 7e155bf commit 17d2c9e
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/GitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,18 @@ class GitClient implements AsyncDisposable {
private async importGPGKey(key: string) {
let keyId: string | undefined;

await exec("gpg", ["--import"], {
const { stdout } = await getExecOutput("gpg", ["--import"], {
input: Buffer.from(key, "utf-8"),
listeners: {
stdout: (data) => {
const match = data
.toString()
.match(/^gpg: key ([0-9A-F]+):/);

if (match) {
keyId = match[1];
}
},
},
});

for (const data of stdout.split(/\n+/)) {
const match = data.match(/^gpg: key ([0-9A-F]+):/);

if (match) {
keyId = match[1];
}
}

if (!keyId) {
throw new Error("Failed to import GPG key.");
}
Expand Down

0 comments on commit 17d2c9e

Please sign in to comment.