Skip to content

Commit

Permalink
Resolved merge request comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartłomiej Świerad committed Nov 3, 2020
1 parent 60e558e commit c0d7e88
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
Expand Up @@ -32,7 +32,7 @@ extension Executor {
task.arguments = command.split(separator: " ").map { String($0) }
if let workingDir = workingDir {
task.currentDirectoryURL = workingDir
task.currentDirectoryPath = workingDir.relativeString
task.currentDirectoryPath = workingDir.path
}
return task
}
Expand Down
26 changes: 5 additions & 21 deletions Scripts/releaseTool/Sources/ReleaseTool/Doers/FileReader.swift
Expand Up @@ -19,10 +19,6 @@ final class FileReader {

// MARK: - Internal
func replaceAll(regex: String, with text: String) {
guard !dryRun else {
console.info("replaceAll: \(regex) with: \(text)")
return
}
guard var content = readFile() else { return }
var newContent = content
repeat {
Expand All @@ -33,32 +29,20 @@ final class FileReader {
}

func replace(firstRegex: String, with text: String) {
guard !dryRun else {
console.info("replaceFirst: \(firstRegex) with: \(text)")
return
}
guard var content = readFile() else { return }
content = replace(firstRegex: firstRegex, with: text, in: content)
writeToFile(text: content)
}

func writeToFile(text: String?) {
guard !dryRun else {
console.info("writeToFile: \(text ?? "<nil>")")
return
}
if fileExists() {
removeFile()
}
createFile(content: text)
}

func readFile() -> String? {
guard !dryRun else {
console.info("readFile")
return nil
}
return readString(encoding: .utf8)
readString(encoding: .utf8)
}

func removeFile() {
Expand All @@ -74,10 +58,6 @@ final class FileReader {
}

func fileExists() -> Bool {
guard !dryRun else {
console.info("fileExists")
return false
}
return fileManager.fileExists(atPath: fileURL.path)
}

Expand Down Expand Up @@ -108,6 +88,10 @@ extension FileReader {
}

private func createFile(content: String?) {
guard !dryRun else {
console.info("writeToFile: \(text ?? "<nil>")")
return
}
fileManager.createFile(
atPath: fileURL.path,
contents: content?.data(using: .utf8))
Expand Down
6 changes: 2 additions & 4 deletions Scripts/releaseTool/Sources/ReleaseTool/Models/Manifest.swift
Expand Up @@ -6,11 +6,9 @@ struct Manifest {

// MARK: - Internal
func versionString(of pod: Pod) -> String {
let finalVersion: String
var finalVersion: String = version
if let betaNumber = pod.betaNumber {
finalVersion = version + "-beta.\(betaNumber)"
} else {
finalVersion = version
finalVersion.append("-beta.\(betaNumber)")
}
return pod.podVersion ?? finalVersion
}
Expand Down
3 changes: 0 additions & 3 deletions Scripts/releaseTool/Sources/ReleaseTool/Models/Pod.swift
Expand Up @@ -4,21 +4,18 @@ struct Pod {
let name: String
let betaNumber: Int?
let allowWarnings: Bool
let podVersion: String?
let releasing: Bool

// MARK: - Initialization
init(
name: String,
betaNumber: Int? = nil,
allowWarnings: Bool = false,
podVersion: String? = nil,
releasing: Bool = true
) {
self.name = name
self.betaNumber = betaNumber
self.allowWarnings = allowWarnings
self.podVersion = podVersion
self.releasing = releasing
}

Expand Down

0 comments on commit c0d7e88

Please sign in to comment.