diff --git a/CHANGELOG.md b/CHANGELOG.md index f5fac34..de70fc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## Next Version +- Fixed edit command removing file attributes #46 @maxchuquimia ## 0.5.1 diff --git a/Sources/BeakCLI/Commands/EditCommand.swift b/Sources/BeakCLI/Commands/EditCommand.swift index 5b35d8a..f45ddbb 100644 --- a/Sources/BeakCLI/Commands/EditCommand.swift +++ b/Sources/BeakCLI/Commands/EditCommand.swift @@ -1,6 +1,7 @@ import PathKit import SwiftCLI import BeakCore +import Foundation class EditCommand: BeakCommand { @@ -39,8 +40,9 @@ class EditCommand: BeakCommand { let line = readLine() if line?.lowercased() == "c" { + let attributes = try FileManager.default.attributesOfItem(atPath: path.string) try path.delete() - try packageManager.mainFilePath.copy(path) + try FileManager.default.createFile(atPath: path.string, contents: packageManager.mainFilePath.read(), attributes: attributes) stdout <<< "Copied edited file back to \(path.string)" } else { stdout <<< "Changes not copied back to \(path.string)"