Skip to content

Commit

Permalink
🥅 :: [#443] 모듈 생성 스크립트 / 디렉토리를 생성할 때, 이미 존재한다면 사용자에게 질의
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Mar 7, 2024
1 parent 8e91a45 commit 0aecc76
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Scripts/GenerateModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@ func registerModulePaths() {

func makeDirectory(path: String) {
do {
try fileManager.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil)
if fileManager.fileExists(atPath: path) {
print("디렉토리를 생성하려는 곳에 이미 디렉토리가 존재해요, 덮어쓰기할까요?\n경로 : \(path)\n(y / n)")
let isOverwrite = readLine()?.lowercased() == "y"
if isOverwrite {
try fileManager.removeItem(atPath: path)
try fileManager.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil)
}
} else {
try fileManager.createDirectory(atPath: path, withIntermediateDirectories: false, attributes: nil)
}
} catch {
fatalError("❌ failed to create directory: \(path)")
}
Expand Down

0 comments on commit 0aecc76

Please sign in to comment.