Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSCBasic: remove some deprecated interfaces in Process #454

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 2 additions & 82 deletions Sources/TSCBasic/Process/Process.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public final class Process {
private static let loggingHandlerLock = NSLock()

/// Global logging handler. Use with care! preferably use instance level instead of setting one globally.
@available(*, deprecated, message: "use instance level `loggingHandler` passed via `init` instead of setting one globally.")
public static var loggingHandler: LoggingHandler? {
get {
Self.loggingHandlerLock.withLock {
Expand All @@ -239,45 +240,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?
compnerd marked this conversation as resolved.
Show resolved Hide resolved

/// The current environment.
@available(*, deprecated, message: "use ProcessEnv.vars instead")
Expand Down Expand Up @@ -377,31 +340,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 +366,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