Skip to content
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

Merged
merged 4 commits into from
Nov 10, 2016

Conversation

jwestbrook
Copy link
Collaborator

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 on STDIN and report the results.

Some problems I've ran into

  • if the php code you are running sets the error level low or off you only get that the parse error exists and what line
  • you only get parse errors as that's what php -l reports (no warnings/deprecated etc)

Todo

  • I need to add config options so that Windows users can point to their php binary or users that don't have php in $PATH

@@ -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){
Copy link
Owner

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?

Copy link
Collaborator Author

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?

Copy link
Owner

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.

@MiguelCastillo
Copy link
Owner

This is really cool!!! :D

@RedDude
Copy link

RedDude commented Nov 10, 2016

This will never be accepted?

@MiguelCastillo MiguelCastillo merged commit 829ae52 into MiguelCastillo:master Nov 10, 2016
@MiguelCastillo
Copy link
Owner

Yes! :)

@MiguelCastillo
Copy link
Owner

@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?

@jwestbrook
Copy link
Collaborator Author

@MiguelCastillo sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants