Skip to content

Commit d5d6b22

Browse files
committed
Remove unsafe API
1 parent e188665 commit d5d6b22

File tree

2 files changed

+0
-58
lines changed

2 files changed

+0
-58
lines changed

Sources/ShellOut.swift

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,6 @@ import ShellQuote
5353
)
5454
}
5555

56-
/**
57-
* Run a series of shell commands using Bash
58-
*
59-
* - parameter commands: The commands to run
60-
* - parameter path: The path to execute the commands at (defaults to current folder)
61-
* - parameter process: Which process to use to perform the command (default: A new one)
62-
* - parameter outputHandle: Any `FileHandle` that any output (STDOUT) should be redirected to
63-
* (at the moment this is only supported on macOS)
64-
* - parameter errorHandle: Any `FileHandle` that any error output (STDERR) should be redirected to
65-
* (at the moment this is only supported on macOS)
66-
* - parameter environment: The environment for the command.
67-
*
68-
* - returns: The output of running the command
69-
* - throws: `ShellOutError` in case the command couldn't be performed, or it returned an error
70-
*
71-
* Use this function to "shell out" in a Swift script or command line tool
72-
* For example: `shellOut(to: ["mkdir NewFolder", "cd NewFolder"], at: "~/CurrentFolder")`
73-
*/
74-
@discardableResult public func shellOut(
75-
to commands: [String],
76-
at path: String = ".",
77-
process: Process = .init(),
78-
outputHandle: FileHandle? = nil,
79-
errorHandle: FileHandle? = nil,
80-
environment: [String : String]? = nil
81-
) throws -> String {
82-
let command = commands.joined(separator: " && ")
83-
84-
return try shellOut(
85-
to: command,
86-
at: path,
87-
process: process,
88-
outputHandle: outputHandle,
89-
errorHandle: errorHandle,
90-
environment: environment
91-
)
92-
}
93-
9456
/**
9557
* Run a pre-defined shell command using Bash
9658
*

Tests/ShellOutTests/ShellOutTests.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,6 @@ class ShellOutTests: XCTestCase {
4545
XCTAssertFalse(homeContents.isEmpty)
4646
}
4747

48-
func testSeriesOfCommands() throws {
49-
let echo = try shellOut(to: ["echo \"Hello\"", "echo \"world\""])
50-
XCTAssertEqual(echo, "Hello\nworld")
51-
}
52-
53-
func testSeriesOfCommandsAtPath() throws {
54-
try shellOut(to: [
55-
"cd \(NSTemporaryDirectory())",
56-
"mkdir -p ShellOutTests",
57-
"echo \"Hello again\" > ShellOutTests/MultipleCommands.txt"
58-
])
59-
60-
let textFileContent = try shellOut(to: [
61-
"cd ShellOutTests",
62-
"cat MultipleCommands.txt"
63-
], at: NSTemporaryDirectory())
64-
65-
XCTAssertEqual(textFileContent, "Hello again")
66-
}
67-
6848
func testThrowingError() {
6949
do {
7050
try shellOut(to: "cd", arguments: ["notADirectory"])

0 commit comments

Comments
 (0)