MCPcopy Create free account
hub / github.com/TanStack/cli / deleteRemovedFiles

Method deleteRemovedFiles

packages/cli/src/file-syncer.ts:231–262  ·  view source on GitHub ↗
(
    targetDir: string,
    previousSourceFiles: Set<string>,
    currentSourceFiles: Set<string>,
    result: SyncResult,
  )

Source from the content-addressed store, hash-verified

229 }
230
231 private async deleteRemovedFiles(
232 targetDir: string,
233 previousSourceFiles: Set<string>,
234 currentSourceFiles: Set<string>,
235 result: SyncResult,
236 ): Promise<void> {
237 for (const relativePath of previousSourceFiles) {
238 if (currentSourceFiles.has(relativePath)) {
239 continue
240 }
241
242 const targetPath = path.join(targetDir, relativePath)
243
244 try {
245 if (!fs.existsSync(targetPath)) {
246 continue
247 }
248
249 const stats = await fs.promises.stat(targetPath)
250 if (!stats.isFile()) {
251 continue
252 }
253
254 await fs.promises.unlink(targetPath)
255 result.deleted.push(relativePath)
256 } catch (error) {
257 result.errors.push(
258 `${relativePath}: ${error instanceof Error ? error.message : String(error)}`,
259 )
260 }
261 }
262 }
263}

Callers 1

syncMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected