psycho-gorilla v1.0.7
psycho-gorilla
Makes integrating local JavaScript files with Gorilla easier by formatting them automatically, allowing a simple copy-paste from a local development environment into Gorilla.
'Main' file
psycho-gorilla can be used with a file in place that contains your jsPsych.init()
method. If specified, this file should be used to setup the timeline and other trial-specific configuration. psycho-gorilla inserts all pre-amble such as importing Gorilla and jsPsych, meaning that only the timeline and jsPsych.init()
must be specified.
File formatting
The script relies on JavaScript files having "tokens" present in comments at the end of the lines to be modified for Gorilla.
Line removal
The token to designate a line for removal is $-
.
Example 1:
let a = 0; // $-
The resulting file will not contain this line.
Line inclusion
The token to designate a line for inclusion is $+
. This should only be used on lines that are commented out already, otherwise the script will produce incorrect code.
Example 2:
// let b = 1; $+
The resulting file will contain the following line:
let b = 1;
Configuration files
psycho-gorilla uses a simple configuration file format that allows specification of the input and output directories and the specific files within the input directory to be formatted and placed in the output directory. The default filename is psycho.config.js
.
module.exports = {
src: 'src',
out: 'dist',
files: {
main: 'main.js',
other: ['file1.js', 'file2.js']
}
}
Use cases
Possible use cases include:
- Insertion of a line that may specify code for a Gorilla manipulation, metric, or resource.
- Corresponding removal of a line used instead in a local development environment.
- Removal of debugging code that is redundant.
- Insertion of TypeScript type definitions otherwise commented-out in a vanilla JavaScript local development environment.
Future work
- Support a HTML file acting as a Gorilla "head".
- Specify actions instead of uncommenting / removing files, given Gorilla's standard format for manipulations, metrics, and resources.
- Example: Specify that a line should be converted into a manipulation or a metric.