• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wurstscript / WurstScript / 249

03 Mar 2024 01:51PM UTC coverage: 62.279% (-0.03%) from 62.309%
249

push

circleci

Frotty
fix map script caching

17278 of 27743 relevant lines covered (62.28%)

0.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
de.peeeq.wurstscript/src/main/java/de/peeeq/wurstio/languageserver/requests/MapRequest.java
1
package de.peeeq.wurstio.languageserver.requests;
2

3
import com.google.common.base.Charsets;
4
import com.google.common.io.Files;
5
import config.WurstProjectConfigData;
6
import de.peeeq.wurstio.Pjass;
7
import de.peeeq.wurstio.TimeTaker;
8
import de.peeeq.wurstio.UtilsIO;
9
import de.peeeq.wurstio.WurstCompilerJassImpl;
10
import de.peeeq.wurstio.languageserver.ModelManager;
11
import de.peeeq.wurstio.languageserver.ProjectConfigBuilder;
12
import de.peeeq.wurstio.languageserver.WFile;
13
import de.peeeq.wurstio.languageserver.WurstLanguageServer;
14
import de.peeeq.wurstio.mpq.MpqEditor;
15
import de.peeeq.wurstio.mpq.MpqEditorFactory;
16
import de.peeeq.wurstio.utils.W3InstallationData;
17
import de.peeeq.wurstscript.RunArgs;
18
import de.peeeq.wurstscript.WLogger;
19
import de.peeeq.wurstscript.ast.CompilationUnit;
20
import de.peeeq.wurstscript.ast.WImport;
21
import de.peeeq.wurstscript.ast.WPackage;
22
import de.peeeq.wurstscript.ast.WurstModel;
23
import de.peeeq.wurstscript.attributes.CompileError;
24
import de.peeeq.wurstscript.gui.WurstGui;
25
import de.peeeq.wurstscript.jassAst.JassProg;
26
import de.peeeq.wurstscript.jassprinter.JassPrinter;
27
import de.peeeq.wurstscript.luaAst.LuaCompilationUnit;
28
import de.peeeq.wurstscript.parser.WPos;
29
import de.peeeq.wurstscript.utils.LineOffsets;
30
import de.peeeq.wurstscript.utils.Utils;
31
import net.moonlightflower.wc3libs.bin.Wc3BinOutputStream;
32
import net.moonlightflower.wc3libs.bin.app.W3I;
33
import net.moonlightflower.wc3libs.port.Orient;
34
import org.apache.commons.lang.StringUtils;
35
import org.eclipse.lsp4j.MessageParams;
36
import org.eclipse.lsp4j.MessageType;
37
import org.eclipse.lsp4j.services.LanguageClient;
38
import org.jetbrains.annotations.Nullable;
39

40
import java.io.ByteArrayOutputStream;
41
import java.io.File;
42
import java.io.FileNotFoundException;
43
import java.io.IOException;
44
import java.nio.channels.NonWritableChannelException;
45
import java.nio.charset.StandardCharsets;
46
import java.nio.file.Path;
47
import java.nio.file.Paths;
48
import java.nio.file.StandardOpenOption;
49
import java.time.Duration;
50
import java.util.*;
51
import java.util.concurrent.CompletableFuture;
52
import java.util.concurrent.atomic.AtomicReference;
53
import java.util.stream.Collectors;
54

55
public abstract class MapRequest extends UserRequest<Object> {
56
    protected final WurstLanguageServer langServer;
57
    protected final Optional<File> map;
58
    protected final List<String> compileArgs;
59
    protected final WFile workspaceRoot;
60
    protected final RunArgs runArgs;
61
    protected final Optional<String> wc3Path;
62
    protected final W3InstallationData w3data;
63
    protected final TimeTaker timeTaker;
64

65
    public static long mapLastModified = 0L;
×
66
    public static String mapPath = "";
×
67

68
    private static Long lastMapModified = 0L;
×
69
    private static String lastMapPath = "";
×
70

71
    /**
72
     * makes the compilation slower, but more safe by discarding results from the editor and working on a copy of the model
73
     */
74
    protected SafetyLevel safeCompilation = SafetyLevel.KindOfSafe;
×
75

76
    public TimeTaker getTimeTaker() {
77
        return timeTaker;
×
78
    }
79

80

81
    enum SafetyLevel {
×
82
        QuickAndDirty, KindOfSafe
×
83
    }
84

85
    public static class CompilationResult {
×
86
        public File script;
87
        public File w3i;
88
    }
89

90
    public MapRequest(WurstLanguageServer langServer, Optional<File> map, List<String> compileArgs, WFile workspaceRoot,
91
                      Optional<String> wc3Path) {
×
92
        this.langServer = langServer;
×
93
        this.map = map;
×
94
        this.compileArgs = compileArgs;
×
95
        this.workspaceRoot = workspaceRoot;
×
96
        this.runArgs = new RunArgs(compileArgs);
×
97
        this.wc3Path = wc3Path;
×
98
        this.w3data = getBestW3InstallationData();
×
99
        if (runArgs.isMeasureTimes()) {
×
100
            this.timeTaker = new TimeTaker.Recording();
×
101
        } else {
102
            this.timeTaker = new TimeTaker.Default();
×
103
        }
104
    }
×
105

106
    @Override
107
    public void handleException(LanguageClient languageClient, Throwable err, CompletableFuture<Object> resFut) {
108
        if (err instanceof RequestFailedException) {
×
109
            RequestFailedException rfe = (RequestFailedException) err;
×
110
            languageClient.showMessage(new MessageParams(rfe.getMessageType(), rfe.getMessage()));
×
111
            resFut.complete(new Object());
×
112
        } else {
×
113
            super.handleException(languageClient, err, resFut);
×
114
        }
115
    }
×
116

117
    protected File compileMap(File projectFolder, WurstGui gui, Optional<File> mapCopy, RunArgs runArgs, WurstModel model,
118
                              WurstProjectConfigData projectConfigData, boolean isProd) {
119
        try (@Nullable MpqEditor mpqEditor = MpqEditorFactory.getEditor(mapCopy)) {
×
120
            if (mpqEditor != null && !mpqEditor.canWrite()) {
×
121
                WLogger.severe("The supplied map is invalid/corrupted/protected and Wurst cannot write to it.\n" +
×
122
                    "Please supply a valid .w3x input map that can be opened in the world editor.");
123
                throw new NonWritableChannelException();
×
124
            }
125
            WurstCompilerJassImpl compiler = new WurstCompilerJassImpl(timeTaker, projectFolder, gui, mpqEditor, runArgs);
×
126
            compiler.setMapFile(mapCopy);
×
127
            purgeUnimportedFiles(model);
×
128

129
            gui.sendProgress("Check program");
×
130
            compiler.checkProg(model);
×
131

132
            if (gui.getErrorCount() > 0) {
×
133
                throw new RequestFailedException(MessageType.Warning, "Could not compile project: ", gui.getErrorList().get(0));
×
134
            }
135

136
            print("translating program ... ");
×
137
            compiler.translateProgToIm(model);
×
138

139
            if (gui.getErrorCount() > 0) {
×
140
                throw new RequestFailedException(MessageType.Error, "Could not compile project (error in translation): " + gui.getErrorList().get(0));
×
141
            }
142

143
            timeTaker.measure("Runinng Compiletime Functions", () -> compiler.runCompiletime(projectConfigData, isProd, runArgs.isCompiletimeCache()));
×
144

145
            if (runArgs.isLua()) {
×
146
                print("Translating program to Lua ... ");
×
147
                Optional<LuaCompilationUnit> luaCode = Optional.ofNullable(compiler.transformProgToLua());
×
148

149
                if (!luaCode.isPresent()) {
×
150
                    print("Could not compile project\n");
×
151
                    throw new RuntimeException("Could not compile project (error in LUA translation)");
×
152
                }
153

154
                StringBuilder sb = new StringBuilder();
×
155
                luaCode.get().print(sb, 0);
×
156

157
                String compiledMapScript = sb.toString();
×
158
                File buildDir = getBuildDir();
×
159
                File outFile = new File(buildDir, "compiled.lua");
×
160
                Files.write(compiledMapScript.getBytes(Charsets.UTF_8), outFile);
×
161
                return outFile;
×
162

163
            } else {
164
                print("Translating program to jass ... ");
×
165
                compiler.transformProgToJass();
×
166

167
                Optional<JassProg> jassProg = Optional.ofNullable(compiler.getProg());
×
168
                if (!jassProg.isPresent()) {
×
169
                    print("Could not compile project\n");
×
170
                    throw new RuntimeException("Could not compile project (error in JASS translation)");
×
171
                }
172

173
                gui.sendProgress("Printing program");
×
174
                JassPrinter printer = new JassPrinter(!runArgs.isOptimize(), jassProg.get());
×
175
                String compiledMapScript = printer.printProg();
×
176
                File buildDir = getBuildDir();
×
177
                File outFile = new File(buildDir, "compiled.j.txt");
×
178
                Files.write(compiledMapScript.getBytes(Charsets.UTF_8), outFile);
×
179

180
                if (!runArgs.isDisablePjass()) {
×
181
                    gui.sendProgress("Running PJass");
×
182
                    Pjass.Result pJassResult = Pjass.runPjass(outFile,
×
183
                        new File(buildDir, "common.j").getAbsolutePath(),
×
184
                        new File(buildDir, "blizzard.j").getAbsolutePath());
×
185
                    WLogger.info(pJassResult.getMessage());
×
186
                    if (!pJassResult.isOk()) {
×
187
                        for (CompileError err : pJassResult.getErrors()) {
×
188
                            gui.sendError(err);
×
189
                        }
×
190
                        throw new RuntimeException("Could not compile project (PJass error)");
×
191
                    }
192
                }
193

194
                if (runArgs.isHotStartmap()) {
×
195
                    gui.sendProgress("Running JHCR");
×
196
                    return runJassHotCodeReload(outFile);
×
197
                }
198
                return outFile;
×
199
            }
200
        } catch (Exception e) {
×
201
            throw new RuntimeException(e);
×
202
        }
203
    }
204

205
    private File runJassHotCodeReload(File mapScript) throws IOException, InterruptedException {
206
        File buildDir = getBuildDir();
×
207
        File commonJ = new File(buildDir, "common.j");
×
208
        File blizzardJ = new File(buildDir, "blizzard.j");
×
209

210
        if (!commonJ.exists()) {
×
211
            throw new IOException("Could not find file " + commonJ.getAbsolutePath());
×
212
        }
213

214
        if (!blizzardJ.exists()) {
×
215
            throw new IOException("Could not find file " + blizzardJ.getAbsolutePath());
×
216
        }
217

218
        ProcessBuilder pb = new ProcessBuilder(langServer.getConfigProvider().getJhcrExe(), "init", commonJ.getName(), blizzardJ.getName(), mapScript.getName());
×
219
        pb.directory(buildDir);
×
220
        Utils.exec(pb, Duration.ofSeconds(30), System.err::println);
×
221
        return new File(buildDir, "jhcr_war3map.j");
×
222
    }
223

224
    /**
225
     * removes everything compilation unit which is neither
226
     * - inside a wurst folder
227
     * - a jass file
228
     * - imported by a file in a wurst folder
229
     */
230
    private void purgeUnimportedFiles(WurstModel model) {
231

232
        Set<CompilationUnit> imported = model.stream()
×
233
            .filter(cu -> isInWurstFolder(cu.getCuInfo().getFile()) || cu.getCuInfo().getFile().endsWith(".j")).collect(Collectors.toSet());
×
234
        addImports(imported, imported);
×
235

236
        model.removeIf(cu -> !imported.contains(cu));
×
237
    }
×
238

239
    private boolean isInWurstFolder(String file) {
240
        Path p = Paths.get(file);
×
241
        Path w;
242
        try {
243
            w = workspaceRoot.getPath();
×
244
        } catch (FileNotFoundException e) {
×
245
            return false;
×
246
        }
×
247
        return p.startsWith(w)
×
248
            && java.nio.file.Files.exists(p)
×
249
            && Utils.isWurstFile(file);
×
250
    }
251

252
    protected File getBuildDir() {
253
        File buildDir;
254
        try {
255
            buildDir = new File(workspaceRoot.getFile(), "_build");
×
256
        } catch (FileNotFoundException e) {
×
257
            throw new RuntimeException("Cannot get build dir", e);
×
258
        }
×
259
        if (!buildDir.exists()) {
×
260
            UtilsIO.mkdirs(buildDir);
×
261
        }
262
        return buildDir;
×
263
    }
264

265
    private void addImports(Set<CompilationUnit> result, Set<CompilationUnit> toAdd) {
266
        Set<CompilationUnit> imported =
×
267
            toAdd.stream()
×
268
                .flatMap((CompilationUnit cu) -> cu.getPackages().stream())
×
269
                .flatMap((WPackage p) -> p.getImports().stream())
×
270
                .map(WImport::attrImportedPackage)
×
271
                .filter(Objects::nonNull)
×
272
                .map(WPackage::attrCompilationUnit)
×
273
                .collect(Collectors.toSet());
×
274
        boolean changed = result.addAll(imported);
×
275
        if (changed) {
×
276
            // recursive call terminates, as there are only finitely many compilation units
277
            addImports(result, imported);
×
278
        }
279
    }
×
280

281
    protected void print(String s) {
282
        WLogger.info(s);
×
283
    }
×
284

285
    protected void println(String s) {
286
        WLogger.info(s);
×
287
    }
×
288

289

290
    protected File compileScript(WurstGui gui, ModelManager modelManager, List<String> compileArgs, Optional<File> mapCopy,
291
                                 WurstProjectConfigData projectConfigData, boolean isProd, File scriptFile) throws Exception {
292
        RunArgs runArgs = new RunArgs(compileArgs);
×
293

294
        gui.sendProgress("Compiling Script");
×
295
        print("Compile Script : ");
×
296
        for (File dep : modelManager.getDependencyWurstFiles()) {
×
297
            WLogger.info("dep: " + dep.getPath());
×
298
        }
×
299
        print("Dependencies done.");
×
300
        if (safeCompilation != RunMap.SafetyLevel.QuickAndDirty) {
×
301
            // it is safer to rebuild the project, instead of taking the current editor state
302
            gui.sendProgress("Cleaning project");
×
303
            modelManager.clean();
×
304
            gui.sendProgress("Building project");
×
305
            modelManager.buildProject();
×
306
        }
307

308
        replaceBaseScriptWithConfig(modelManager, scriptFile);
×
309

310
        if (modelManager.hasErrors()) {
×
311
            for (CompileError compileError : modelManager.getParseErrors()) {
×
312
                gui.sendError(compileError);
×
313
            }
×
314
            throw new RequestFailedException(MessageType.Warning, "Cannot run code with syntax errors.");
×
315
        }
316

317
        WurstModel model = modelManager.getModel();
×
318
        if (safeCompilation != RunMap.SafetyLevel.QuickAndDirty) {
×
319
            // compilation will alter the model (e.g. remove unused imports),
320
            // so it is safer to create a copy
321
            model = ModelManager.copy(model);
×
322
        }
323

324
        return compileMap(modelManager.getProjectPath(), gui, mapCopy, runArgs, model, projectConfigData, isProd);
×
325
    }
326

327
    private static void replaceBaseScriptWithConfig(ModelManager modelManager, File scriptFile) throws IOException {
328
        Optional<CompilationUnit> war3mapJ = modelManager.getModel()
×
329
            .stream()
×
330
            .filter((CompilationUnit cu) -> cu.getCuInfo().getFile().endsWith("war3map.j"))
×
331
            .findFirst();
×
332

333
        if (war3mapJ.isPresent()) {
×
334
            modelManager.syncCompilationUnitContent(WFile.create(war3mapJ.get().getCuInfo().getFile()),
×
335
                java.nio.file.Files.readString(scriptFile.toPath()));
×
336
        }
337
    }
×
338

339

340
    protected CompilationResult compileScript(ModelManager modelManager, WurstGui gui, Optional<File> testMap, WurstProjectConfigData projectConfigData, File buildDir, boolean isProd) throws Exception {
341
        if (testMap.isPresent() && testMap.get().exists()) {
×
342
            boolean deleteOk = testMap.get().delete();
×
343
            if (!deleteOk) {
×
344
                throw new RequestFailedException(MessageType.Error, "Could not delete old mapfile: " + testMap);
×
345
            }
346
        }
347
        if (map.isPresent() && testMap.isPresent()) {
×
348
            Files.copy(map.get(), testMap.get());
×
349
        }
350

351
        CompilationResult result;
352

353
        if (runArgs.isHotReload()) {
×
354
            // For hot reload use cached war3map if it exists
355
            result = new CompilationResult();
×
356
            result.script = new File(buildDir, "war3mapj_with_config.j.txt");
×
357
            if (!result.script.exists()) {
×
358
                result.script = new File(new File(workspaceRoot.getFile(), "wurst"), "war3map.j");
×
359
            }
360
            if (!result.script.exists()) {
×
361
                throw new RequestFailedException(MessageType.Error, "Could not find war3map.j file");
×
362
            }
363
        } else {
364
            timeTaker.beginPhase("load map script");
×
365
            File scriptFile = loadMapScript(testMap, modelManager, gui);
×
366
            timeTaker.endPhase();
×
367
            result = applyProjectConfig(gui, testMap, buildDir, projectConfigData, scriptFile);
×
368
        }
369

370

371
        // first compile the script:
372
        result.script = compileScript(gui, modelManager, compileArgs, testMap, projectConfigData, isProd, result.script);
×
373

374
        Optional<WurstModel> model = Optional.ofNullable(modelManager.getModel());
×
375
        if (!model.isPresent()
×
376
            || model
377
            .get()
×
378
            .stream()
×
379
            .noneMatch((CompilationUnit cu) -> cu.getCuInfo().getFile().endsWith("war3map.j"))) {
×
380
            println("No 'war3map.j' file could be found inside the map nor inside the wurst folder");
×
381
            println("If you compile the map with WurstPack once, this file should be in your wurst-folder. ");
×
382
            println("We will try to start the map now, but it will probably fail. ");
×
383
        }
384
        return result;
×
385
    }
386

387

388
    private File loadMapScript(Optional<File> mapCopy, ModelManager modelManager, WurstGui gui) throws Exception {
389
        File scriptFile = new File(new File(workspaceRoot.getFile(), "wurst"), "war3map.j");
×
390
        // If runargs are no extract, either use existing or throw error
391
        // Otherwise try loading from map, if map was saved with wurst, try existing script, otherwise error
392
        if (!mapCopy.isPresent() || runArgs.isNoExtractMapScript()) {
×
393
            if (scriptFile.exists()) {
×
394
                modelManager.syncCompilationUnit(WFile.create(scriptFile));
×
395
                return scriptFile;
×
396
            } else {
397
                throw new CompileError(new WPos("", new LineOffsets(), 0, 0),
×
398
                    "RunArg noExtractMapScript is set but no mapscript is provided inside the wurst folder");
399
            }
400
        }
401
        if (MapRequest.mapLastModified > lastMapModified || !MapRequest.mapPath.equals(lastMapPath)) {
×
402
            lastMapModified = MapRequest.mapLastModified;
×
403
            lastMapPath = MapRequest.mapPath;
×
404
            System.out.println("Map not cached yet, extracting script");
×
405
            byte[] extractedScript = null;
×
406
            try (@Nullable MpqEditor mpqEditor = MpqEditorFactory.getEditor(mapCopy, true)) {
×
407
                if (mpqEditor.hasFile("war3map.j")) {
×
408
                    extractedScript = mpqEditor.extractFile("war3map.j");
×
409
                }
410
            }
411
            if (extractedScript == null) {
×
412
                if (scriptFile.exists()) {
×
413
                    String msg = "No war3map.j in map file, using old extracted file";
×
414
                    WLogger.info(msg);
×
415
                } else {
×
416
                    CompileError err = new CompileError(new WPos(mapCopy.toString(), new LineOffsets(), 0, 0),
×
417
                        "No war3map.j found in map file.");
418
                    gui.showInfoMessage(err.getMessage());
×
419
                    WLogger.severe(err);
×
420
                }
×
421
            } else if (new String(extractedScript, StandardCharsets.UTF_8).startsWith(JassPrinter.WURST_COMMENT_RAW)) {
×
422
                WLogger.info("map has already been compiled with wurst");
×
423
                // file generated by wurst, do not use
424
                if (scriptFile.exists()) {
×
425
                    String msg = "Cannot use war3map.j from map file, because it already was compiled with wurst. " + "Using war3map.j from Wurst directory instead.";
×
426
                    WLogger.info(msg);
×
427
                } else {
×
428
                    CompileError err = new CompileError(new WPos(mapCopy.toString(), new LineOffsets(), 0, 0),
×
429
                        "Cannot use war3map.j from map file, because it already was compiled with wurst. " + "Please add war3map.j to the wurst directory.");
430
                    gui.showInfoMessage(err.getMessage());
×
431
                    WLogger.severe(err);
×
432
                }
×
433
            } else {
434
                WLogger.info("new map, use extracted");
×
435
                // write mapfile from map to workspace
436
                Files.write(extractedScript, scriptFile);
×
437
            }
438
        } else {
×
439
            System.out.println("Map not modified, not extracting script");
×
440
        }
441

442

443
        return scriptFile;
×
444
    }
445

446
    private CompilationResult applyProjectConfig(WurstGui gui, Optional<File> testMap, File buildDir, WurstProjectConfigData projectConfig, File scriptFile) {
447
        AtomicReference<CompilationResult> result = new AtomicReference<>();
×
448
        gui.sendProgress("Applying Map Config...");
×
449
        timeTaker.measure("Applying Map Config", () -> {
×
450
            try {
451
                result.set(ProjectConfigBuilder.apply(projectConfig, testMap.get(), scriptFile, buildDir, runArgs, w3data));
×
452
            } catch (IOException e) {
×
453
                throw new RuntimeException(e);
×
454
            }
×
455
        });
×
456
        return result.get();
×
457
    }
458

459
    private W3InstallationData getBestW3InstallationData() throws RequestFailedException {
460
        if (Orient.isLinuxSystem()) {
×
461
            // no Warcraft installation supported on Linux
462
            return new W3InstallationData(Optional.empty(), Optional.empty());
×
463
        }
464
        if (wc3Path.isPresent() && StringUtils.isNotBlank(wc3Path.get())) {
×
465
            W3InstallationData w3data = new W3InstallationData(langServer, new File(wc3Path.get()),
×
466
                this instanceof RunMap && !runArgs.isHotReload());
×
467
            if (w3data.getWc3PatchVersion().isEmpty()) {
×
468
                throw new RequestFailedException(MessageType.Error, "Could not find Warcraft III installation at specified path: " + wc3Path);
×
469
            }
470

471
            return w3data;
×
472
        } else {
473
            return new W3InstallationData(langServer, this instanceof RunMap && !runArgs.isHotReload());
×
474
        }
475
    }
476

477
    protected void injectMapData(WurstGui gui, Optional<File> testMap, CompilationResult result) throws Exception {
478
        gui.sendProgress("Injecting map data");
×
479
        try (MpqEditor mpqEditor = MpqEditorFactory.getEditor(testMap)) {
×
480
            String mapScriptName;
481
            if (runArgs.isLua()) {
×
482
                mapScriptName = "war3map.lua";
×
483
                injectExternalLuaFiles(result.script);
×
484
            } else {
485
                mapScriptName = "war3map.j";
×
486
            }
487
            // delete both original mapscripts, just to be sure:
488
            mpqEditor.deleteFile("war3map.j");
×
489
            mpqEditor.deleteFile("war3map.lua");
×
490
            if (result.w3i != null) {
×
491
                mpqEditor.deleteFile(W3I.GAME_PATH.getName());
×
492
                mpqEditor.insertFile(W3I.GAME_PATH.getName(), result.w3i);
×
493
            }
494
            mpqEditor.insertFile(mapScriptName, result.script);
×
495
        }
496
    }
×
497

498
    private void injectExternalLuaFiles(File script) {
499
        File luaDir;
500
        try {
501
            luaDir = new File(workspaceRoot.getFile(), "lua");
×
502
        } catch (FileNotFoundException e) {
×
503
            throw new RuntimeException("Cannot get build dir", e);
×
504
        }
×
505
        if (luaDir.exists()) {
×
506
            File[] children = luaDir.listFiles();
×
507
            if (children != null) {
×
508
                Arrays.stream(children).forEach(child -> {
×
509
                    try {
510
                        byte[] bytes = java.nio.file.Files.readAllBytes(child.toPath());
×
511
                        if (child.getName().startsWith("pre_")) {
×
512
                            byte[] existingBytes = java.nio.file.Files.readAllBytes(script.toPath());
×
513
                            java.nio.file.Files.write(
×
514
                                script.toPath(),
×
515
                                bytes);
516
                            java.nio.file.Files.write(
×
517
                                script.toPath(),
×
518
                                existingBytes,
519
                                StandardOpenOption.APPEND);
520
                        } else {
×
521
                            java.nio.file.Files.write(
×
522
                                script.toPath(),
×
523
                                bytes,
524
                                StandardOpenOption.APPEND);
525
                        }
526
                    } catch (IOException e) {
×
527
                        throw new RuntimeException(e);
×
528
                    }
×
529
                });
×
530
            }
531
        }
532
    }
×
533

534

535
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc