From 99f37de695119fd643b36f373771bcdcc4a626af Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 30 Jan 2021 20:22:47 -0500 Subject: Move direct command-line execution from test/js to docs/bqn.js --- docs/bqn.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) mode change 100644 => 100755 docs/bqn.js (limited to 'docs/bqn.js') diff --git a/docs/bqn.js b/docs/bqn.js old mode 100644 new mode 100755 index 406c20f8..c3c2d1ba --- 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)+''); + } + }); + } } -- cgit v1.2.3