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 1, 2019
1 parent 0349297 commit eca2e3c
Showing 1 changed file with 3 additions and 1 deletion.
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 eca2e3c

Please sign in to comment.