geowarin/boot-react

Latest YarnRunner fails on Windows

MikeSuiter opened this issue · 3 comments

This fix worked for me on Windows.

  private ProcessExecutor command(String... cmd) {
    if (isWindows()) {
      List<String> args = new ArrayList<>(Arrays.asList("cmd", "/c"));
      args.addAll(Arrays.asList(cmd));
      return new ProcessExecutor().command(args);
    }
    return new ProcessExecutor().command(Arrays.asList(cmd));
  }

Whoops sorry! Forgot about Array.asList returning an immutable list!

That being said the code is really ugly, any way to make it better ?

This might be a little cleaner and seems to work on Windows.

  private ProcessExecutor command(String... cmd) {
    List<String> args = new ArrayList<>(Arrays.asList(cmd));
    if (isWindows()) {
      args.addAll(0, Arrays.asList("cmd", "/c"));
    }
    return new ProcessExecutor().command(args);
  }