mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Resilience fixes
This commit is contained in:
parent
56930c07a6
commit
454e8aea75
1 changed files with 20 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
|||
package io.xpipe.core.process;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -61,6 +63,10 @@ public class CommandBuilder {
|
|||
|
||||
public CommandBuilder addQuoted(String s) {
|
||||
elements.add(sc -> {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (sc == null) {
|
||||
return "\"" + s + "\"";
|
||||
}
|
||||
|
@ -102,6 +108,10 @@ public class CommandBuilder {
|
|||
|
||||
public CommandBuilder addFile(String s) {
|
||||
elements.add(sc -> {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (sc == null) {
|
||||
return "\"" + s + "\"";
|
||||
}
|
||||
|
@ -128,13 +138,17 @@ public class CommandBuilder {
|
|||
return sc.command(this);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public String buildSimple() {
|
||||
return String.join(" ", elements.stream().map(element -> {
|
||||
try {
|
||||
return element.evaluate(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Element element : elements) {
|
||||
String evaluate = element.evaluate(null);
|
||||
if (evaluate == null) {
|
||||
continue;
|
||||
}
|
||||
}).toList());
|
||||
|
||||
list.add(evaluate);
|
||||
}
|
||||
return String.join(" ", list);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue