NAME
qgoda javascript - Execute JavaScript code inside Qgoda
SYNOPSIS
qgoda javascript [<global options>] [-i|--input=FILENAME]
[-g|--global=MODULE_DIR1] [-g|--global=MODULE_DIR2]
[--input-data=DATA]
[--input-format=JSON|YAML|Perl|Storable]
[--no-stdout] [--no-stderr]
[FILENAME...]
Try 'qgoda --help' for a description of global options.
DESCRIPTION
Executes JavaScript code inside Qgoda, using the embedded JavaScript engine Duktape. This is not meant as a serious JavaScript interpreter or command-line frontend to Duktape but rather a debugging aid for Qgoda.
You have to pass a filename containing JavaScript code as an argument or prove the code on standard input.
Note that Duktape is not NodeJS! Not all constructs accepted by NodeJS are accepted by Duktape!
Qgoda, however, implements a module resolver so that you can use constructs like:
const _ = require('lodash');
The module is resolved in the same way that NodeJS would resolve it. See the option --global below for more information.
OPTIONS
- -i, --input=FILENAME
-
Data stored in FILENAME is assigned to the global JavaScript variable
__perl__.input
. This is the common convention for JavaScript code in Qgoda for injecting input variables to JavaScript code. - --input-format=FORMAT
-
The input format used for input data. Must be one of:
- JSON
- YAML
-
See http://yaml.org.
- Perl
-
The input will be evaluated as Perl code. You can produce such input manually or with Data::Dumper or Data::Dump.
- Storable
-
Data that can be deserialized with Storable::thaw().
The default is "JSON". Case does not matter.
- --input-data=DATA
-
Like --input but the data is not read from a file but from the string DATA. The data format is determined by --input-format.
- -g|--global=DIRECTORY
-
Prepend DIRECTORY to the list of global directories to search for JavaScript modules. The default is the Qgoda package directory, that is the same path where Qgoda.pm is installed but without the trailing .pm.
The DIRECTORY should be specified without the trailing node_modules.
- --no-console
-
Do not use Qgoda's console polyfill but that of Duktape itself. Note that the Duktape console polyfill only supports
console.log()
! - --no-output
-
Save standard output and standard error instead of printing it to the console. The output is available later by calling
Qgoda-
new->jsout> resp.Qgoda-
new->jserr>. This is useful for unit testing only. - -h, --help
-
Show this help page and exit.
SEE ALSO
qgoda(1), Qgoda::JavaScript::Environment, JavaScript::Duktape::XS, Data::Dumper, Data::Dump, Storable, https://www.json.org/, http://yaml.org, https://duktape.org/, https://nodejs.org
QGODA
Part of Qgoda.