From 6f30dc055027c0c2c3bd1040e7b6c87758535df5 Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Tue, 29 Oct 2024 07:48:42 -0400 Subject: [PATCH] Restore ability to cat key into `ssh-key add` Change-type: patch --- src/commands/ssh-key/add.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commands/ssh-key/add.ts b/src/commands/ssh-key/add.ts index 4180792b..46522742 100644 --- a/src/commands/ssh-key/add.ts +++ b/src/commands/ssh-key/add.ts @@ -16,7 +16,6 @@ */ import { Args, Command } from '@oclif/core'; -import { ExpectedError } from '../../errors'; import { getBalenaSdk, stripIndent } from '../../utils/lazy'; export default class SSHKeyAddCmd extends Command { @@ -59,6 +58,7 @@ export default class SSHKeyAddCmd extends Command { }), path: Args.string({ description: `the path to the public key file`, + required: true, }), }; @@ -67,12 +67,12 @@ export default class SSHKeyAddCmd extends Command { public async run() { const { args: params } = await this.parse(SSHKeyAddCmd); + const { readFile } = (await import('fs')).promises; let key: string; - if (params.path != null) { - const { readFile } = (await import('fs')).promises; + try { key = await readFile(params.path, 'utf8'); - } else { - throw new ExpectedError('No public key file or path provided.'); + } catch { + key = params.path; } await getBalenaSdk().models.key.create(params.name, key);