probmods / webppl-viz

Visualization for WebPPL
http://probmods.github.io/webppl-viz/
Other
14 stars 9 forks source link

Automatically open graphs #86

Closed smihael closed 6 years ago

smihael commented 6 years ago

There should be an option to automatically open rendered graphs, when running webppl from command line.

The following patch to index.js does that by default:

@@ -3,6 +3,7 @@
 var $ = require('jquery');
 var dependencyAnalysis = require('./dependency-analysis');
 var reflection = require('./reflection');
+var open = require("open");

 global.d3 = d3;

@@ -1039,6 +1040,7 @@

                     require('fs').writeFileSync(fileName, svgText);
                     console.log("Rendered to " + fileName);
+                    open(fileName)
                     util.trampolineRunners.cli()( options.callback() )
                   });
longouyang commented 6 years ago

Can you submit a pull request for this that also only auto-opens if a certain environment variable is defined?