Skip to content

Commit

Permalink
Use the PLUGIN_FILE_CONTENT environment variable to create a file
Browse files Browse the repository at this point in the history
  • Loading branch information
woohyunjin06 committed Jul 14, 2022
1 parent a5079d3 commit 2ce2b13
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"state": {
"branch": null,
"revision": "54d7d05bbe4ea1666400999acefb0ebbc23e91d8",
"version": "3.8.0"
"version": null
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/tuist/ProjectAutomation", .exact("3.8.0")),
.package(url: "https://github.com/tuist/ProjectAutomation", .revisionItem("54d7d05bbe4ea1666400999acefb0ebbc23e91d8")),
],
targets: [
.target(
Expand Down
8 changes: 6 additions & 2 deletions Sources/CreateFile/main.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Foundation

try "File created with a plugin".write(
let contentKey = "PLUGIN_FILE_CONTENT"
guard let content = ProcessInfo.processInfo.environment[contentKey] else {
fatalError("Environment variable not found: '\(contentKey)'.")
}
try content.write(
to: URL(fileURLWithPath: "plugin-file.txt"),
atomically: true,
encoding: .utf8
)
print("File created with a plugin!")
print("File created with a plugin!")

0 comments on commit 2ce2b13

Please sign in to comment.