markushedvall / node-plantuml

A Node.js module and CLI for running PlantUML
MIT License
193 stars 53 forks source link

Script doesn't return when calling generate(...) #23

Closed stijnherreman closed 5 years ago

stijnherreman commented 6 years ago

Consider the following script:

const fs = require("fs-extra");
const glob = require("glob");
const plantuml = require("node-plantuml");

glob("src/**/*.plantuml", (err, matches) => {
  if (err) throw err;

  for (let sourceFilePath of matches) {
    const fileContent = fs.readFileSync(sourceFilePath);
    const uml = plantuml.generate(fileContent);

    const targetFilePath = sourceFilePath
      .replace(new RegExp("^src/"), "dist/")
      .replace(new RegExp(".plantuml$"), ".svg");

    // uml.out.pipe(fs.createWriteStream(targetFilePath));

    console.log(`${sourceFilePath} => ${targetFilePath}`);
  }
});

It will not return (making me stop the script with Ctrl-C) when the const uml = plantuml.generate(fileContent); line is there. It works fine otherwise. Any idea what' wrong?

stijnherreman commented 6 years ago

My bad, fileContent isn't text as expected by generate(...). An error message would be helpful though, I had to debug the script and step through the generate(...) code.

markushedvall commented 6 years ago

I'll see if I can replicate the behaviour, but if it's hanging on generate as you say. Then it is more likely plantuml itself that is the culprit, making hard to report errors. I could be wrong though. Maybe you saw where it got stuck while you were stepping through the generate code?

markushedvall commented 5 years ago

I've been unable to reproduce this issue myself, and as mentioned in the previous post it is most likely due to Plantuml getting stuck when processing the file.