diff --git a/lib/deps/graph.js b/lib/deps/graph.js index 3b9c5b5..6ae35c3 100644 --- a/lib/deps/graph.js +++ b/lib/deps/graph.js @@ -410,6 +410,9 @@ Graph.prototype.render = function(type_or_options, name_or_callback, errback) { } } else { graphviz = spawn(cmdPath, parameters); + graphviz.on('error', function(err) { + errback(-1, "", err) + }); graphviz.stdout.on('data', outcallback); graphviz.stderr.on('data', function(data) { err += data; @@ -424,8 +427,10 @@ Graph.prototype.render = function(type_or_options, name_or_callback, errback) { else if (errback) errback(code, out, err) } }); - graphviz.stdin.write(self.to_dot()); - graphviz.stdin.end(); + if (graphviz.pid) { + graphviz.stdin.write(self.to_dot()); + graphviz.stdin.end(); + } } }); };