Skip to content

Commit 305dbaf

Browse files
committed
chore: added {;} replacement
1 parent 1e13f70 commit 305dbaf

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Actions support several variable substitution features for cross-platform compat
143143
- **`{~}`** - Replaced with the user's home directory (The actual path on Windows, `~` on Linux/Mac)
144144
- **`{./path/to/file}`** - Converts relative paths to platform-specific format
145145
- **`{./libs:./ext:~/usrlibs}`** - Converts entire class paths to platform-specific format
146+
- **`{;}`** - For use with multi-command actions (`&` on Windows, `;` on Linux/Mac). Really not _that_ useful, you can use `&&` instead which works on all platforms
146147
147148
Example with cross-platform compatibility:
148149

src/main/java/org/codejive/jpm/util/ScriptUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static String processCommand(String command, List<Path> classpath) {
7878
}
7979

8080
// Find all occurrences of {./...} and {~/...} and replace them with os paths
81+
// This also handles classpath constructs with multiple paths separated by :
8182
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\{([.~]/[^}]*)}");
8283
java.util.regex.Matcher matcher = pattern.matcher(result);
8384
StringBuilder sb = new StringBuilder();
@@ -110,13 +111,19 @@ static String processCommand(String command, List<Path> classpath) {
110111
matcher.appendTail(sb);
111112
result = sb.toString();
112113

114+
// Special replacements for dealing with paths and classpath separators
115+
// in cross-platform way
113116
result = result.replace("{/}", File.separator);
114117
result = result.replace("{:}", File.pathSeparator);
115118
result =
116119
result.replace(
117120
"{~}",
118121
isWindows() ? Paths.get(System.getProperty("user.home")).toString() : "~");
119122

123+
// Special replacement {;} for dealing with multi-command actions in a
124+
// cross-platform way
125+
result = result.replace("{;}", isWindows() ? "&" : ";");
126+
120127
return result;
121128
}
122129

0 commit comments

Comments
 (0)