@hongaar
:wave: hi all. Is anybody aware if a coordinated attempt to keep vorpal alive?
Would you be open to be part of it? :)
src
for our tests.
node myapp.js
will open an interactive session and prompt for commands; node myapp.js mycmd myarg
will run a command and return to the command-prompt. Is there a way of giving one or more commands on the command-line and then switching to accepting commands interactively? At the moment, after command-definition, I've got vorpal.parse( process.argv ).show() ;
. TIA
const commands = require('require-all')(__dirname + '/commands');
const _ = require("lodash")
_.forOwn(commands, function(value, key) {
vorpal.use(value)
});
each command just follows this format:
module.exports = function(vorpal, options){
// insert vorpal command here
}
the-cli a
only imports and executes code from a.js
while never touching files for b and c (or similar).
But I suppose you can mitigate it by doing this (based on your snippet of code)
module.exports = function(vorpal, options){
const dep = require('dependency-needed-by-your-command')
dep.foo()
}
instead of
const dep = require('dependency-needed-by-your-command')
module.exports = function(vorpal, options){
dep.foo()
}
Each command imports all of its dependencies only when called.