MCPcopy Index your code
hub / github.com/coder/mux / resolveSSHConfigWritePath

Function resolveSSHConfigWritePath

src/node/runtime/muxSshConfigWriter.ts:147–173  ·  view source on GitHub ↗
(sshConfigPath: string)

Source from the content-addressed store, hash-verified

145}
146
147async function resolveSSHConfigWritePath(sshConfigPath: string): Promise<string> {
148 try {
149 const stats = await fs.lstat(sshConfigPath);
150 if (!stats.isSymbolicLink()) {
151 return sshConfigPath;
152 }
153
154 try {
155 // Fast path: realpath follows full chain when target exists.
156 return await fs.realpath(sshConfigPath);
157 } catch (error) {
158 if ((error as NodeJS.ErrnoException | undefined)?.code === "ENOENT") {
159 // Dangling symlink: target doesn't exist yet.
160 // Manually follow the chain to find the intended write target.
161 return await followSymlinkChain(sshConfigPath);
162 }
163 throw error;
164 }
165 } catch (error) {
166 if ((error as NodeJS.ErrnoException | undefined)?.code === "ENOENT") {
167 // Path itself doesn't exist (not even as a symlink).
168 return sshConfigPath;
169 }
170
171 throw error;
172 }
173}
174
175async function loadSSHConfigContent(
176 sshConfigPath: string

Callers 1

Calls 1

followSymlinkChainFunction · 0.85

Tested by

no test coverage detected