-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
split out embed/thread plugins and add PHP plugin #182
Conversation
@@ -33,7 +33,12 @@ define(function(require, exports, module){ | |||
var _lint = plugin.lint; | |||
|
|||
function lint(text, settings) { | |||
return Promise.resolve(_lint(text, settings)); | |||
var results = _lint(text, settings,pluginsMeta); | |||
if(results.promise !== undefined && results.promise !== null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find where result gets a promise added as a property... Why is that needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I'm checking to see if the lint()
method returns a promise or a standard object.
At line 15 in plugins/default/embedded/php/main.js I setup a Promise to be returned - the Promise object has a promise
property /shrug it should probably be checking in a better way I guess.
I needed to use a promise as the child_process.exec()
method is async - so the results of the process would not be available when the lint()
method @ line 7 returns. So then I followed the data flow (which crossed my eyes a few times) and at this point ^^ you are resolving the Promise with the lint results from whichever plugin is returning. So instead I passed the Promise through.
does that explain it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwestbrook apologies for the terribly slow response.
Promise.resolve will gracefully convert input objects to promises... And input promises are basically a noop. That's a good way to uniformly handle promises and non promises objects consistently.
return Promise.resolve(_lint(text, settings, pluginsMeta));
Should be sufficient.
This is really cool!!! :D |
This will never be accepted? |
Yes! :) |
@jwestbrook there are some tweaks that should be made to the implementation... I merged it as is. and we can make the tweaks in separate PRs. Any interest in being added as a contributor? |
@MiguelCastillo sure |
Per discussion on #172 I've changed the plugin loading to determine if the plugin is loading from embedded or threaded folders and load them accordingly.
Then I added the php plugin I wrote to take advantage of the node connection and run
php -l
from the command line based onSTDIN
and report the results.Some problems I've ran into
php -l
reports (no warnings/deprecated etc)Todo