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

Function setCwd

src/utils/Shell.ts:448–475  ·  view source on GitHub ↗
(path: string, relativeTo?: string)

Source from the content-addressed store, hash-verified

446 * Set the current working directory
447 */
448export function setCwd(path: string, relativeTo?: string): void {
449 const resolved = isAbsolute(path)
450 ? path
451 : resolve(relativeTo || getFsImplementation().cwd(), path)
452 // Resolve symlinks to match the behavior of pwd -P.
453 // realpathSync throws ENOENT if the path doesn't exist - convert to a
454 // friendlier error message instead of a separate existsSync pre-check (TOCTOU).
455 let physicalPath: string
456 try {
457 physicalPath = getFsImplementation().realpathSync(resolved)
458 } catch (e) {
459 if (isENOENT(e)) {
460 throw new Error(`Path "${resolved}" does not exist`)
461 }
462 throw e
463 }
464
465 setCwdState(physicalPath)
466 if (process.env.NODE_ENV !== 'test') {
467 try {
468 logEvent('ncode_shell_set_cwd', {
469 success: true,
470 })
471 } catch (_error) {
472 // Ignore logging errors to prevent test failures
473 }
474 }
475}

Callers 10

execFunction · 0.70
restoreWorktreeForResumeFunction · 0.70
exitRestoredWorktreeFunction · 0.70
submitMessageMethod · 0.50
runFunction · 0.50
setupFunction · 0.50
loadChangesFunction · 0.50
handleSelectFunction · 0.50
clearConversationFunction · 0.50
startMCPServerFunction · 0.50

Calls 5

getFsImplementationFunction · 0.85
isENOENTFunction · 0.85
setCwdStateFunction · 0.85
resolveFunction · 0.70
logEventFunction · 0.50

Tested by

no test coverage detected