Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ private Path getTsgenPath() {
var runner = new GeneratorShellRunner(baseDir.toFile(), nodeCommand,
arguments);
runner.run(null, (stdOutStream) -> {
new BufferedReader(new InputStreamReader(stdOutStream)).lines()
.limit(1).forEach(pathLine::set);
// Consume all output from Node
var lines = new BufferedReader(
new InputStreamReader(stdOutStream)).lines().toList();
lines.stream().limit(1).forEach(pathLine::set);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What has changed here exactly?

}, null);
if (pathLine.get() == null) {
throw new CommandRunnerException("No output from Node");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.vaadin.hilla.engine.commandrunner;

import com.vaadin.flow.server.frontend.FrontendUtils;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;

import java.io.*;
Expand Down Expand Up @@ -178,12 +179,18 @@ private void executeCommand(String executable, String[] arguments,
.of(new Pipe<>(stdOut, process.getInputStream()),
new Pipe<>(stdErr, process.getErrorStream()),
new Pipe<>(stdIn, process.getOutputStream()))
.filter(handler -> handler.consumer() != null)
.map(handler -> {
var t = new Thread(() -> {
try (var stream = handler.stream()) {
((Consumer<Closeable>) handler.consumer())
.accept(stream);
var stream = handler.stream();
try {
if (handler.consumer() != null) {
((Consumer<Closeable>) handler.consumer())
.accept(stream);
} else if (stream instanceof InputStream inputStream) {
// make sure the stream is consumed
// to avoid deadlock
IOUtils.consume(inputStream);
}
} catch (IOException e) {
getLogger().error("Error while handling stream",
e);
Expand Down
7 changes: 6 additions & 1 deletion packages/ts/generator-plugin-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ export default class ClientPlugin extends Plugin {

static async #checkForCustomClientFile(path?: string): Promise<boolean> {
const dir = path?.startsWith('file:') ? fileURLToPath(path) : path;
if (!dir) {
return false;
}

try {
return !!(dir && (await open(`${dir}/${ClientPlugin.CUSTOM_CLIENT_FILE_NAME}.ts`, 'r')));
const fileHandle = await open(`${dir}/${ClientPlugin.CUSTOM_CLIENT_FILE_NAME}.ts`, 'r');
await fileHandle.close();
return true;
} catch {
return false;
}
Expand Down
Loading