This is the actual jdi
executable which is being declared as bin
in the
package.json
file. Whenever a user runs jdi
, this is the file that is
being run.
We're using commander
for
parsing command line arguments and generating the --help
output. We tried
out vorpal
as well, but it
significantly increases startup time, which we obviously want to avoid.
const program = require('commander')
The package.json
is our source of truth.
const version = require('./package.json').version
const jdi = require('.')
jdi
uses the glob
module for
filename expansion. If your shell already handles that for you (e.g. if
you're using fish
), you can optionally quote the filenames that you want to
expand, e.g. like this:
$ jdi 'src/**/*.js'
const glob = require('glob')
const flatten = require('flatten')
This is where we declare our jdi
command. Currently there are no
sub-commands, but this might change in the future as jdi
grows.
program
.version(version)
.parse(process.argv)
Expand glob patterns to actual filenames. This is going to run **/*.js
into
an array of actually existing files.
const filenames = flatten(
program.args
.map(pattern => glob.sync(pattern))
)
Here we actually invoke run
and start execution.
jdi.run(process.cwd(), filenames)
Generated Wed Aug 17 2016 21:45:13 GMT+0100 (BST) from Ⓢ jdi