From 60911ea634f781a29077ceda707e0e13c24633fa Mon Sep 17 00:00:00 2001 From: Todd Hainsworth Date: Thu, 10 Apr 2025 14:56:13 +0930 Subject: [PATCH] fix: assume when stat fails that the dir does not exist --- lib/ssh.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ssh.ts b/lib/ssh.ts index 1a2f79a..5357ea8 100644 --- a/lib/ssh.ts +++ b/lib/ssh.ts @@ -15,10 +15,11 @@ export async function setupSshCredentials(): Promise { const identityFile = `${sshConfigDir}/id_rsa_tmp`; const knownHostsFile = `${sshConfigDir}/known_hosts`; - // Ensure the SSH directory exists + // Ensure the SSH directory exists, when `stat` throws an error, we know the directory doesn't exist const sshDirExists = await fs.promises .stat(sshDir) - .then((stat) => stat.isDirectory()); + .then((stat) => stat.isDirectory()) + .catch((err) => false); if (!sshDirExists) { await fs.promises.mkdir(sshDir, { recursive: true }); }