file-helper.ts — ui Source File
Architecture documentation for file-helper.ts, a typescript file in the ui codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5e0b8913_8282_ccaa_2dde_fb3097bbbf0c["file-helper.ts"] f9f5e551_eb59_1a6b_8bf2_b97e73eb13de["fs-extra"] 5e0b8913_8282_ccaa_2dde_fb3097bbbf0c --> f9f5e551_eb59_1a6b_8bf2_b97e73eb13de style 5e0b8913_8282_ccaa_2dde_fb3097bbbf0c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fsExtra from "fs-extra"
export const FILE_BACKUP_SUFFIX = ".bak"
export function createFileBackup(filePath: string): string | null {
if (!fsExtra.existsSync(filePath)) {
return null
}
const backupPath = `${filePath}${FILE_BACKUP_SUFFIX}`
try {
fsExtra.renameSync(filePath, backupPath)
return backupPath
} catch (error) {
console.error(`Failed to create backup of ${filePath}: ${error}`)
return null
}
}
export function restoreFileBackup(filePath: string): boolean {
const backupPath = `${filePath}${FILE_BACKUP_SUFFIX}`
if (!fsExtra.existsSync(backupPath)) {
return false
}
try {
fsExtra.renameSync(backupPath, filePath)
return true
} catch (error) {
console.error(
`Warning: Could not restore backup file ${backupPath}: ${error}`
)
return false
}
}
export function deleteFileBackup(filePath: string): boolean {
const backupPath = `${filePath}${FILE_BACKUP_SUFFIX}`
if (!fsExtra.existsSync(backupPath)) {
return false
}
try {
fsExtra.unlinkSync(backupPath)
return true
} catch (error) {
// Best effort - don't log as this is just cleanup
return false
}
}
Domain
Subdomains
Dependencies
- fs-extra
Source
Frequently Asked Questions
What does file-helper.ts do?
file-helper.ts is a source file in the ui codebase, written in typescript. It belongs to the FrameworkTooling domain, CLICore subdomain.
What functions are defined in file-helper.ts?
file-helper.ts defines 3 function(s): createFileBackup, deleteFileBackup, restoreFileBackup.
What does file-helper.ts depend on?
file-helper.ts imports 1 module(s): fs-extra.
Where is file-helper.ts in the architecture?
file-helper.ts is located at packages/shadcn/src/utils/file-helper.ts (domain: FrameworkTooling, subdomain: CLICore, directory: packages/shadcn/src/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free