Skip to content

Commit

Permalink
feat: add strict-ssl configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
error418 committed Sep 25, 2019
1 parent 56308f5 commit e7c6aea
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/groovy/de/illjut/gradle/semrel/SemrelPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class SemrelPlugin implements Plugin<Project> {

def config = new SemanticReleaseConfig(project.rootProject.file(".releaserc.yml"))
def execConfig = ExecConfig.instance()
.registry(config.npmConfig?.registry);
.registry(config.npmConfig?.registry)
.strictSsl(config.npmConfig?.strictSsl);

def nodeVersion = config.nodeVersion;

Expand Down
24 changes: 21 additions & 3 deletions src/main/java/de/illjut/gradle/semrel/ExecConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

public class ExecConfig {
private String registry = null;
private Optional<String> registry = Optional.empty();
private Optional<String> strictSsl = Optional.empty();

public static ExecConfig instance() {
return new ExecConfig();
Expand All @@ -15,14 +17,30 @@ private ExecConfig() {
}

public ExecConfig registry(String registry) {
this.registry = registry;
this.registry = Optional.ofNullable(registry);
return this;
}

public ExecConfig strictSsl(Boolean strictSsl) {
if (strictSsl == null) {
this.strictSsl = Optional.empty();
} else {
this.strictSsl = Optional.of(String.valueOf(strictSsl.booleanValue()));
}
return this;
}

private void putToMap(Map<String, String> map, String key, Optional<String> value) {
if (value.isPresent()) {
map.put(key, value.get());
}
}

public Map<String, String> buildEnvVarMap() {
Map<String, String> envVars = new HashMap<String, String>();

envVars.put("npm_config_registry", this.registry);
this.putToMap(envVars, "npm_config_registry", this.registry);
this.putToMap(envVars, "npm_config_strict_ssl", this.strictSsl);

return envVars;
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/de/illjut/gradle/semrel/NodeExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ private ProcessResult exec(List<String> command, File workDir, File nodePathOver

if (pathVar != null) processBuilder.environment().put(pathVar, pathValue);

processBuilder.environment().putAll(this.execConfig.buildEnvVarMap());
if(this.execConfig != null) {
processBuilder.environment().putAll(this.execConfig.buildEnvVarMap());
}

Process proc = processBuilder.start();

Expand Down

0 comments on commit e7c6aea

Please sign in to comment.