Skip to content

Commit

Permalink
Fix Tree.printDotGraph ignoring fd
Browse files Browse the repository at this point in the history
Fixes #202
  • Loading branch information
segevfiner committed Jul 5, 2024
1 parent d07a2ad commit f81f3d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Napi::Value Parser::SetLogger(const Napi::CallbackInfo &info) {

Napi::Value Parser::PrintDotGraphs(const Napi::CallbackInfo &info) {
bool should_print = true;
int32_t fd = fileno(stderr);
int fd = fileno(stderr);

if (info.Length() > 0) {
if (!info[0].IsBoolean()) {
Expand Down
11 changes: 10 additions & 1 deletion src/tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,16 @@ Napi::Value Tree::GetEditedRange(const Napi::CallbackInfo &info) {
}

Napi::Value Tree::PrintDotGraph(const Napi::CallbackInfo &info) {
ts_tree_print_dot_graph(tree_, fileno(stderr));
int fd = fileno(stderr);

if (info.Length() > 1) {
if (!info[1].IsNumber()) {
throw TypeError::New(info.Env(), "Second argument must be a number");
}
fd = info[1].As<Number>().Int32Value();
}

ts_tree_print_dot_graph(tree_, fd);
return info.This();
}

Expand Down

0 comments on commit f81f3d0

Please sign in to comment.