Skip to content

Commit

Permalink
TSCBasic: remove some deprecated interfaces in Process
Browse files Browse the repository at this point in the history
These interfaces were deprecated in 2022, remove these now.  While there
were some instances of the `init` still in use.  Thanks to @MaxDesiatov
and @weissi for the help to verify the safe removal of these deprecated
interfaces.
  • Loading branch information
compnerd committed Dec 18, 2023
1 parent 91d1a0b commit d6ea45d
Showing 1 changed file with 1 addition and 82 deletions.
83 changes: 1 addition & 82 deletions Sources/TSCBasic/Process/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,45 +239,7 @@ public final class Process {
}
}

// deprecated 2/2022, remove once client migrate to logging handler
@available(*, deprecated)
public static var verbose: Bool {
get {
Self.loggingHandler != nil
} set {
Self.loggingHandler = newValue ? Self.logToStdout: .none
}
}

private var _loggingHandler: LoggingHandler?

// the log and setter are only required to backward support verbose setter.
// remove and make loggingHandler a let property once verbose is deprecated
private let loggingHandlerLock = NSLock()
public private(set) var loggingHandler: LoggingHandler? {
get {
self.loggingHandlerLock.withLock {
self._loggingHandler
}
}
set {
self.loggingHandlerLock.withLock {
self._loggingHandler = newValue
}
}
}

// deprecated 2/2022, remove once client migrate to logging handler
// also simplify loggingHandler (see above) once this is removed
@available(*, deprecated)
public var verbose: Bool {
get {
self.loggingHandler != nil
}
set {
self.loggingHandler = newValue ? Self.logToStdout : .none
}
}
public let loggingHandler: LoggingHandler?

/// The current environment.
@available(*, deprecated, message: "use ProcessEnv.vars instead")
Expand Down Expand Up @@ -377,31 +339,6 @@ public final class Process {
self.loggingHandler = loggingHandler ?? Process.loggingHandler
}

// deprecated 2/2022
@_disfavoredOverload
@available(*, deprecated, message: "use version without verbosity flag")
@available(macOS 10.15, *)
public convenience init(
arguments: [String],
environment: [String: String] = ProcessEnv.vars,
workingDirectory: AbsolutePath,
outputRedirection: OutputRedirection = .collect,
verbose: Bool,
startNewProcessGroup: Bool = true
) {
self.init(
arguments: arguments,
environment: environment,
workingDirectory: workingDirectory,
outputRedirection: outputRedirection,
startNewProcessGroup: startNewProcessGroup,
loggingHandler: verbose ? { message in
stdoutStream.send(message).send("\n")
stdoutStream.flush()
} : nil
)
}

/// Create a new process instance.
///
/// - Parameters:
Expand All @@ -428,24 +365,6 @@ public final class Process {
self.loggingHandler = loggingHandler ?? Process.loggingHandler
}

@_disfavoredOverload
@available(*, deprecated, message: "use version without verbosity flag")
public convenience init(
arguments: [String],
environment: [String: String] = ProcessEnv.vars,
outputRedirection: OutputRedirection = .collect,
verbose: Bool = Process.verbose,
startNewProcessGroup: Bool = true
) {
self.init(
arguments: arguments,
environment: environment,
outputRedirection: outputRedirection,
startNewProcessGroup: startNewProcessGroup,
loggingHandler: verbose ? Self.logToStdout : .none
)
}

public convenience init(
args: String...,
environment: [String: String] = ProcessEnv.vars,
Expand Down

0 comments on commit d6ea45d

Please sign in to comment.