Skip to content

Commit

Permalink
Merge pull request #46 from maxchuquimia/master
Browse files Browse the repository at this point in the history
Ensure edited file's attributes remain intact
  • Loading branch information
yonaskolb authored Dec 2, 2019
2 parents 1dcbd49 + 904c0ac commit 0711ea4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 0711ea4

Please sign in to comment.