Skip to content

Commit

Permalink
Improve Graphviz support detection
Browse files Browse the repository at this point in the history
Previous implementation was assuming that an error was always caused by
the Graphviz binary not available in the path.

However an error can also be thrown when Graphviz is missing
an external dependencies for example.

As far as I know ENOENT stands for a no entry error which
indicates that something wasn't found. In this case it should
be safe to assume that Graphviz isn't available in the path.

See: https://stackoverflow.com/q/66602685/1244884
  • Loading branch information
customcommander committed Mar 12, 2021
1 parent 03b7ba0 commit a03392a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ async function checkGraphvizInstalled(config) {
try {
await exec(cmd, ['-V']);
} catch (err) {
throw new Error(`Graphviz could not be found. Ensure that "gvpr" is in your $PATH. ${err}`);
if (err.code === "ENOENT") {
throw new Error(`Graphviz could not be found. Ensure that "gvpr" is in your $PATH. ${err}`);
} else {
throw new Error(`Unexpected error when calling Graphviz "${cmd}". ${err}`);
}
}
}

Expand Down

0 comments on commit a03392a

Please sign in to comment.