MCPcopy Index your code
hub / github.com/21st-dev/1code / saveWorktreeConfig

Function saveWorktreeConfig

src/main/lib/git/worktree-config.ts:112–144  ·  view source on GitHub ↗
(
  projectPath: string,
  config: WorktreeConfig,
  target: "cursor" | "1code" | string = "1code",
)

Source from the content-addressed store, hash-verified

110 * Creates parent directories if needed
111 */
112export async function saveWorktreeConfig(
113 projectPath: string,
114 config: WorktreeConfig,
115 target: "cursor" | "1code" | string = "1code",
116): Promise<{ success: boolean; path: string; error?: string }> {
117 let targetPath: string
118
119 if (target === "cursor") {
120 targetPath = join(projectPath, CURSOR_CONFIG_PATH)
121 } else if (target === "1code") {
122 targetPath = join(projectPath, ONECODE_CONFIG_PATH)
123 } else {
124 // Custom path
125 targetPath = isAbsolute(target) ? target : join(projectPath, target)
126 }
127
128 try {
129 // Create parent directory
130 await mkdir(dirname(targetPath), { recursive: true })
131
132 // Write config
133 const content = JSON.stringify(config, null, 2)
134 await writeFile(targetPath, content, "utf-8")
135
136 return { success: true, path: targetPath }
137 } catch (error) {
138 return {
139 success: false,
140 path: targetPath,
141 error: error instanceof Error ? error.message : "Unknown error",
142 }
143 }
144}
145
146/**
147 * Get setup commands for current platform

Callers 1

worktree-config.tsFile · 0.90

Calls 1

writeFileFunction · 0.85

Tested by

no test coverage detected