Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
refactor: expose plugin utils & add initial tests #484
Conversation
@@ -6,13 +6,7 @@ | |||
// http://github.com/arturadib/shelljs | |||
// | |||
|
|||
var commonPath = './src/common'; |
ariporad
Jul 27, 2016
Contributor
Why are we deleting this?
Why are we deleting this?
@ariporad I just fixed the issue with node v0.10-12. This should be good now. |
For reference, the bug I found with the approach in #482 is that there are two different instances of A plugin might signal an error using |
LGTM! |
8f7a7d8
into
master
After more experimentation, I realized that #482 wasn't a perfect approach, but that this would be a better one. Even after #482,
shell.error()
was actually broken. This fixes that issue.This also starts differentiating internal implementations (
src/common.js
) from exposed parts of the plugin API (plugin.js
). This is of course still far from a complete plugin API, but this should be enough to make simple plugins (and still get benefits like globbing, shelljs-style error signaling, etc.).All implementations are still within
src/common.js
, and internal commands still rely on that directly, but external plugins are intended to usevar plugin = require('shelljs/plugin')
to get functions likeplugin.register()
. This also makes it easy to modify the plugin API without breaking ShellJS commands.I also started unit tests for the plugin API. This creates one sample plugin (with all the bells and whistles like automatic option parsing) and then makes sure it works properly. We may also want to create a simpler plugin (i.e. no automatic option-parsing, no wrapping the return value, etc.) and test that.
If you have any suggestions on naming conventions, or think there's a better approach to this issue, let me know. Like I said, this is still far from complete, but suggestions are welcome.