Skip to content

Commit

Permalink
Ensure edited file's attributes remain intact
Browse files Browse the repository at this point in the history
  • Loading branch information
maxchuquimia authored and maxc-streamotion committed Dec 2, 2019
1 parent 0349297 commit 904c0ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
# Change Log

## Next Version
- Fixed edit command removing file attributes #46 @maxchuquimia

## 0.5.1

Expand Down
4 changes: 3 additions & 1 deletion Sources/BeakCLI/Commands/EditCommand.swift
@@ -1,6 +1,7 @@
import PathKit
import SwiftCLI
import BeakCore
import Foundation

class EditCommand: BeakCommand {

Expand Down Expand Up @@ -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)"
Expand Down

0 comments on commit 904c0ac

Please sign in to comment.