cli-engine icon indicating copy to clipboard operation
cli-engine copied to clipboard

improved command loading

Open jdx opened this issue 7 years ago • 3 comments

Command loading could be improved in 2 ways. First, every plugin has to manually require each command or otherwise do something involving klaw to find every .js file in the commands directory. This is unneeded boilerplate I think we could do with out for either scenario.

Also, right now when a plugin is loaded it must require() every command in the plugin. Ideally we could instead use some kind of introspection to find all the commands in a plugin that follow a convention (sort of like how rails files work).

So if you had commands such as (the babel-generated) ./lib/commands/foo/bar.js it shouldn't have to be referenced in an index file. The CLI could list out all the js files under lib/commands. Then during plugin loading we could just require the command about to be run, not all the commands in the CLI improving load times.

jdx avatar Mar 14 '17 19:03 jdx

+1

cwallsfdc avatar Apr 04 '17 17:04 cwallsfdc

For reference, you can improve your plugin's performance by following this lazy loaded command example.

No changes to cli-engine needed for now.

RasPhilCo avatar May 24 '17 17:05 RasPhilCo

Moving to open w/ hopes-and-dreams re: file name conventions

RasPhilCo avatar May 24 '17 18:05 RasPhilCo