Skip to content

Commit

Permalink
fix: set PATH variable on dist invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
error418 committed Aug 29, 2019
1 parent 24d7518 commit 6c8367d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/de/illjut/gradle/semrel/NodeExec.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,28 @@ private ProcessResult exec(List<String> command, File workDir) throws IOExceptio
}

private ProcessResult exec(List<String> command, File workDir, File nodePathOverride) throws IOException {
String pathVar = null, pathValue = null;

if (nodePathOverride != null) {
command.set(0, this.nodePath.getAbsolutePath() + "/" + command.get(0));
this.logger.info("using executable {}", command.get(0));

this.logger.info("using custom node path {}", nodePathOverride);
if (System.getenv("Path") != null) {
pathVar = "Path";
} else {
pathVar = "PATH";
}
pathValue = nodePathOverride + File.pathSeparator + System.getenv(pathVar);
}

try {
ProcessBuilder processBuilder = new ProcessBuilder(command)
.directory(workDir)
.redirectErrorStream(true);

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

Process proc = processBuilder.start();

LogStream logStream = new LogStream(this.logger, proc.getInputStream());
Expand Down

0 comments on commit 6c8367d

Please sign in to comment.