Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dotenv support #337

Merged
merged 1 commit into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
implementation 'net.lingala.zip4j:zip4j:1.3.2'
implementation 'net.ricecode:string-similarity:1.0.0'
implementation 'com.github.fge:json-patch:1.9'
compile 'io.github.cdimascio:dotenv-java:2.2.0'

implementation 'org.apache.httpcomponents:httpclient:4.5.3'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.crowdin.cli.properties;

import com.crowdin.cli.commands.Outputter;
import io.github.cdimascio.dotenv.Dotenv;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;

Expand All @@ -25,6 +26,8 @@
*/
public abstract class PropertiesBuilder<T extends Properties, P extends Params> {

private static final Dotenv dotenv = Dotenv.configure().ignoreIfMissing().load();

public static final String PROJECT_ID = "project_id";

public static final String PROJECT_ID_ENV = "project_id_env";
Expand Down Expand Up @@ -208,7 +211,7 @@ static Map<String, Object> getMap(Map<String, Object> map, String key) {

static void setEnvOrPropertyIfExists(Consumer<String> setter, Map<String, Object> properties, String envKey, String key) {
String param = properties.containsKey(envKey)
? System.getenv(properties.get(envKey).toString())
? dotenv.get(properties.get(envKey).toString())
: (properties.containsKey(key))
? (properties.get(key) != null) ? properties.get(key).toString() : null
: null;
Expand Down