-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from rogusdev/parent-dir-env-files
Search for .env file higher than current/given dir
- Loading branch information
Showing
10 changed files
with
374 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TEST="See DotNetEnvTraverse.Tests for why this is here" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace DotNetEnv | ||
{ | ||
public class LoadOptions | ||
{ | ||
public static readonly LoadOptions DEFAULT = new LoadOptions(); | ||
|
||
public bool SetEnvVars { get; } | ||
public bool ClobberExistingVars { get; } | ||
public bool OnlyExactPath { get; } | ||
|
||
public LoadOptions( | ||
bool setEnvVars = true, | ||
bool clobberExistingVars = true, | ||
bool onlyExactPath = true | ||
) { | ||
SetEnvVars = setEnvVars; | ||
ClobberExistingVars = clobberExistingVars; | ||
OnlyExactPath = onlyExactPath; | ||
} | ||
|
||
public LoadOptions( | ||
LoadOptions old, | ||
bool? setEnvVars = null, | ||
bool? clobberExistingVars = null, | ||
bool? onlyExactPath = null | ||
) { | ||
SetEnvVars = setEnvVars ?? old.SetEnvVars; | ||
ClobberExistingVars = clobberExistingVars ?? old.ClobberExistingVars; | ||
OnlyExactPath = onlyExactPath ?? old.OnlyExactPath; | ||
} | ||
|
||
public static LoadOptions NoEnvVars (LoadOptions options = null) => | ||
options == null ? DEFAULT.NoEnvVars() : options.NoEnvVars(); | ||
|
||
public static LoadOptions NoClobber (LoadOptions options = null) => | ||
options == null ? DEFAULT.NoClobber() : options.NoClobber(); | ||
|
||
public static LoadOptions TraversePath (LoadOptions options = null) => | ||
options == null ? DEFAULT.TraversePath() : options.TraversePath(); | ||
|
||
public LoadOptions NoEnvVars () => new LoadOptions(this, setEnvVars: false); | ||
public LoadOptions NoClobber () => new LoadOptions(this, clobberExistingVars: false); | ||
public LoadOptions TraversePath () => new LoadOptions(this, onlyExactPath: false); | ||
|
||
public IEnumerable<KeyValuePair<string, string>> Load (string path = null) => Env.Load(path, this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TEST=here |
Oops, something went wrong.