|
5 | 5 |
|
6 | 6 | import java.io.File; |
7 | 7 | import java.util.Arrays; |
| 8 | +import java.util.Optional; |
8 | 9 |
|
9 | 10 | import org.apache.commons.lang3.StringUtils; |
10 | 11 |
|
@@ -99,13 +100,13 @@ protected File doApply(MacPackager packager) throws Exception { |
99 | 100 | // mounts image |
100 | 101 | Logger.info("Mounting image: " + tempDmgFile.getAbsolutePath()); |
101 | 102 | String result = execute("hdiutil", "attach", "-readwrite", "-noverify", "-noautoopen", tempDmgFile); |
102 | | - StringdeviceName = Arrays.asList(result.split("\n")) |
103 | | - .stream() |
104 | | - .filter(s -> s.contains(mountFolder.getAbsolutePath())) |
105 | | - .map(s -> StringUtils.normalizeSpace(s)) |
106 | | - .map(s -> s.split(" ")[0]) |
107 | | - .findFirst().get(); |
108 | | - Logger.info("- Device name: " + deviceName); |
| 103 | + Optional<String> optDeviceName = Arrays.asList(result.split("\n")) |
| 104 | + .stream() |
| 105 | + .filter(s -> s.contains(mountFolder.getAbsolutePath())) |
| 106 | + .map(s -> StringUtils.normalizeSpace(s)) |
| 107 | + .map(s -> s.split(" ")[0]) |
| 108 | + .findFirst(); |
| 109 | + optDeviceName.ifPresent(deviceName -> Logger.info("- Device name: " + deviceName)); |
109 | 110 |
|
110 | 111 | // pause to prevent occasional "Can't get disk" (-1728) issues |
111 | 112 | // https://github.com/seltzered/create-dmg/commit/5fe7802917bb85b40c0630b026d33e421db914ea |
|
0 commit comments