fix: resolve a cylcic-dependency problem#482
Conversation
If a plugin was imported before the ShellJS instance was created, the program would crash (common.register wouldn't be instantiated yet). Now plugins can be imported either before or after the ShellJS instance is created.
|
Also, this should have no influence whatsoever on ShellJS when used normally, but would only help make plugins a bit easier 😄 |
|
I'm not really sure I understand how this helps... Could you explain it? Other than that, LGTM. |
|
@ariporad A plugin would If the plugin is included before the ShellJS instance is created ( The problem didn't arise for normal ShellJS use because The solution here is to check if Hopefully that's a good explanation. I had to draw out dependency graphs to discover what the problem was and how to solve it. From what I've seen, however, it seems to work. I'll update the plugin after this is merged as a proof of concept. |
|
Ahh... That makes sense. Thanks! |
|
Yeah, it's a bit non-intuitive, but hopefully that was a clear enough explanation for all looking into the matter in the future. |
If a plugin was imported before the ShellJS instance was created, the user's script would crash (
common.registerwouldn't be instantiated yet). Now plugins can be imported either before or after the ShellJS instance is created.One really cool consequence of this fix is that now plugins are compatible with the
shelljs/globalscript:Another cool consequence is that this would allow me to rewrite shelljs-exec-proxy as a ShellJS plugin, which would let it play nicely with other plugins (such as shelljs-plugin-open).