Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion R/launch.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ run <- function(dataIn) {

# process and return
if (inherits(captured, "error")) {
call <- conditionCall(captured)
msg <- conditionMessage(captured)
cat("Error in R script", .e$path, "\n", sQuote(msg), file = stderr())
cat("Error in R script", .e$path, "\n", sQuote(call), "\n", sQuote(msg), file = stderr())
return(invisible(F))
}
.e$out$x <- if (is.null(temp)) {
Expand Down
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ R.prototype.call = function(_opts, _callback) {
var opts = _.isFunction(_opts) ? {} : _opts;
this.options.env.input = JSON.stringify([this.d, this.path, opts]);
var child = child_process.spawn("Rscript", this.args, this.options);
child.stderr.on("data", callback);
var stdout = "";
var stderr = "";
child.stderr.on("data", function(d) {
stderr += d.toString();
});
child.stdout.on("data", function(d) {
callback(null, JSON.parse(d));
stdout += d;
});
child.on("close", function(code) {
callback(
stderr ? stderr : null,
stdout ? JSON.parse(stdout) : {}
);
});
};

Expand Down