Skip to content

Commit

Permalink
Merge pull request #23 from thebarndog/release/2.0.1
Browse files Browse the repository at this point in the history
[Release] - 2.0.1
  • Loading branch information
thebarndog authored Feb 19, 2024
2 parents 349dd63 + 1783b3d commit f6e7ca8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ A one-stop shop for working with environment values in a Swift program.

## Overview

`SwiftDotenv` is a small and compact Swift package that allows you to load and save `.env` files at runtime and query for those values as well as system provided environemntal values via `ProcessInfo`. It's a single abstraction for dealing with environment variables at runtime as well as a handy mechanism keeping your secrets and private keys safe in a local configuration file that doesn't get committed to version control, rather than hardcoding secret strings into your app or framework.
`SwiftDotenv` is a small and compact Swift package that allows you to load and save `.env` files at runtime and query for those values as well as system provided environemntal values via `ProcessInfo`. It's a single abstraction for dealing with environment variables at runtime in a local configuration file that doesn't get committed to version control, rather than hardcoding strings into your app or framework.

**IMPORTANT**: Please note that storing secrets or other sensitive information in the `.env` file does not necessarily make your app secure. For more information, see [this great article from NSHipster](https://nshipster.com/secrets/).

### What is a `.env` file?

Expand Down
8 changes: 3 additions & 5 deletions Sources/Dotenv.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ public enum Dotenv {
/// - value: Value to set.
/// - key: Key to set the value with.
/// - overwrite: Flag that indicates if any existing value should be overwritten, defaults to `true`.
public static func set(value: Value, forKey key: String, overwrite: Bool = true) {
set(value: value.stringValue, forKey: key, overwrite: overwrite)
public static func set(value: Value?, forKey key: String, overwrite: Bool = true) {
set(value: value?.stringValue, forKey: key, overwrite: overwrite)
}

/// Set a value in the environment.
/// - Parameters:
/// - value: Value to set.
/// - key: Key to set the value with.
/// - overwrite: Flag that indicates if any existing value should be overwritten, defaults to `true`.
public static func set(value: String, forKey key: String, overwrite: Bool = true) {
public static func set(value: String?, forKey key: String, overwrite: Bool = true) {
setenv(key, value, overwrite ? 1 : 0)
}

Expand All @@ -173,7 +173,6 @@ public enum Dotenv {
get {
Value(values[key])
} set {
guard let newValue else { return }
set(value: newValue, forKey: key)
}
}
Expand All @@ -192,7 +191,6 @@ public enum Dotenv {
get {
Value(values[member.camelCaseToSnakeCase().uppercased()])
} set {
guard let newValue else { return }
set(value: newValue, forKey: member.camelCaseToSnakeCase().uppercased())
}
}
Expand Down
7 changes: 0 additions & 7 deletions Sources/String+CamelCase.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//
// String+CamelCase.swift
// SwiftDotenv
//
// Created by Brendan Conron on 5/6/22.
//

import Foundation

extension String {
Expand Down

0 comments on commit f6e7ca8

Please sign in to comment.