Skip to content

Commit

Permalink
Merge pull request #3 from woohyunjin06/create-file-with-env
Browse files Browse the repository at this point in the history
Update `create-file` plugin to use the `PLUGIN_FILE_CONTENT` environment variable
  • Loading branch information
danieleformichelli authored Jul 19, 2022
2 parents a5079d3 + 095a195 commit 87c1ac2
Showing 1 changed file with 6 additions and 2 deletions.
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 87c1ac2

Please sign in to comment.