Skip to content

Commit 3b7d5b7

Browse files
Merge pull request #16 from aligent/fix/stat-assume-no-dir
fix: assume when stat fails that the dir does not exist
2 parents 7c08ee6 + 60911ea commit 3b7d5b7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/ssh.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ export async function setupSshCredentials(): Promise<void> {
1515
const identityFile = `${sshConfigDir}/id_rsa_tmp`;
1616
const knownHostsFile = `${sshConfigDir}/known_hosts`;
1717

18-
// Ensure the SSH directory exists
18+
// Ensure the SSH directory exists, when `stat` throws an error, we know the directory doesn't exist
1919
const sshDirExists = await fs.promises
2020
.stat(sshDir)
21-
.then((stat) => stat.isDirectory());
21+
.then((stat) => stat.isDirectory())
22+
.catch((err) => false);
2223
if (!sshDirExists) {
2324
await fs.promises.mkdir(sshDir, { recursive: true });
2425
}

0 commit comments

Comments
 (0)