MCPcopy Create free account
hub / github.com/Noumena-Network/code / removeDirectoryIfEmpty

Function removeDirectoryIfEmpty

src/utils/nativeInstaller/installer.ts:611–625  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

609
610// Exported for testing
611export async function removeDirectoryIfEmpty(path: string): Promise<void> {
612 // rmdir alone handles all cases: ENOTDIR if path is a file, ENOTEMPTY if
613 // directory is non-empty, ENOENT if missing. No need to stat+readdir first.
614 try {
615 await rmdir(path)
616 logForDebugging(`Removed empty directory at ${path}`)
617 } catch (error) {
618 const code = getErrnoCode(error)
619 // Expected cases (not-a-dir, missing, not-empty) — silently skip.
620 // ENOTDIR is the normal path: executablePath is typically a symlink.
621 if (code !== 'ENOTDIR' && code !== 'ENOENT' && code !== 'ENOTEMPTY') {
622 logForDebugging(`Could not remove directory at ${path}: ${error}`)
623 }
624 }
625}
626
627async function updateSymlink(
628 symlinkPath: string,

Callers 1

performVersionUpdateFunction · 0.85

Calls 3

rmdirFunction · 0.85
getErrnoCodeFunction · 0.85
logForDebuggingFunction · 0.50

Tested by

no test coverage detected