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

execute tasks on over "mainWindow.reload()" #22

Open
scottcorgan opened this issue Jul 31, 2015 · 5 comments
Open

execute tasks on over "mainWindow.reload()" #22

scottcorgan opened this issue Jul 31, 2015 · 5 comments

Comments

@scottcorgan
Copy link

Running a linter before every test run is a practice that's become a habit for me. Would there be an easy way to include a way to execute given tasks before the main window reloads?

@mattdesl
Copy link
Collaborator

Could be a pretty neat browserify transform or plugin! Would be useful outside of hihat as well. Just prints lint errors to console in the same way that error handling currently re-writes the bundle.

@scottcorgan
Copy link
Author

Interesting to make it a plugin. How would the linter push the results to the console?

@mattdesl
Copy link
Collaborator

Hmm, for example running eslint programmatically on **/*.js files in the current working dir. A browserify plugin do something similar to what hihat does now for error reporting. See errorify for a more detailed implementation.

I'm open to other ideas, though. If there was a "pre-run" task like a child process, how would it send errors and details to the DevTools console? Maybe just using webContents.executeJavaScript?

@scottcorgan
Copy link
Author

Well, I suppose since Electron is on unified event loop, spawning a child task and checking its exit code shouldn't be overwhelmingly complicated.

Maybe before calling mainWindow.reload(), a set of tasks to run good be executed, followed by the reload() call. (https://github.com/Jam3/hihat/blob/master/index.js#L141).

I guess the question to give it context is in which environment do the tasks get executed, the mainWindow or the terminal session?

@mattdesl
Copy link
Collaborator

mattdesl commented Aug 1, 2015

I made a prototype using standard since it has a pretty easy API.
https://github.com/mattdesl/standardify

hihat index.js -- -p standardify

It probably wouldn't be much harder to do the same with eslint or your favourite linter. The DOM stuff is not necessary in your case and you could prettify the console logs a bit if you are mainly targeting chrome/hihat.

The child task idea is pretty cool, too. It might be useful for various things other than linting. It could just pipe the process' stdout (or stderr?) into the DevTools console.

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

No branches or pull requests

2 participants