aboutsummaryrefslogtreecommitdiff
path: root/docs/bqn.js
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-30 20:22:47 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-30 20:22:47 -0500
commit99f37de695119fd643b36f373771bcdcc4a626af (patch)
treed30db1ea6cfe1dda0685b271f124f968d5accae5 /docs/bqn.js
parent5ecf5494573e7c4f554329646edf072e2bd6cb7c (diff)
Move direct command-line execution from test/js to docs/bqn.js
Diffstat (limited to 'docs/bqn.js')
-rwxr-xr-x[-rw-r--r--]docs/bqn.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/bqn.js b/docs/bqn.js
index 406c20f8..c3c2d1ba 100644..100755
--- a/docs/bqn.js
+++ b/docs/bqn.js
@@ -1,3 +1,5 @@
+#! /usr/bin/env node
+
"use strict";
// Virtual machine
let has = x => x!==undefined;
@@ -286,4 +288,14 @@ let fmtErr = (s,e) => {
if (typeof module!=='undefined') {
bqn.fmt=fmt; bqn.fmtErr=fmtErr; bqn.compile=compile; bqn.run=run;
module.exports=bqn;
+ if (!module.parent) {
+ let args = process.argv.slice(2);
+ args.map(a=>{
+ try {
+ console.log(fmt(bqn(a)))
+ } catch(e) {
+ console.error(''+fmtErr(Array.from(a),e)+'');
+ }
+ });
+ }
}