diff --git a/Viewer/features/cli.js b/Viewer/features/cli.js index f2b62f2d..d822933a 100755 --- a/Viewer/features/cli.js +++ b/Viewer/features/cli.js @@ -241,9 +241,29 @@ var CLIActions = actions.Actions({ // print banner... //XXX + var code repl .start({ - prompt: 'ig> ', + ...(process.stdin.isTTY ? + // interactive... + { + prompt: 'ig> ', + } + // non-tty / non-interactive repl... + : { + terminal: false, + prompt: '', + // XXX HACK??? + // collect the code... + // NOTE: we are using a custom eval here as it + // seems that there is no way to either + // disable the default writer or to define + // an alternative that would not output \n's + // per non-empty line of input... + eval: function(cmd, context, filename, callback) { + code = code ?? '' + code += cmd + '\n' } + }), useGlobal: true, @@ -253,6 +273,11 @@ var CLIActions = actions.Actions({ //ignoreUndefined: true, }) .on('exit', function(){ + // XXX HACK??? + // run collected code... + if(code){ + var AsyncFunction = (async function(){}).constructor + AsyncFunction(code)() } that.stop() }) }], // XXX move this to a feature that requires electron... // ...and move electron to an optional dependency... diff --git a/Viewer/package.json b/Viewer/package.json index 0082d2b3..e1557345 100644 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -1,7 +1,7 @@ { "name": "ImageGrid.Viewer.g4", "main": "index.html", - "version": "4.0.5a", + "version": "4.0.6a", "author": "Alex A. Naanou (https://github.com/flynx)", "contributors": [], "repository": "github:flynx/ImageGrid",