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

[request] Multiple preload scripts #2406

Closed
mattdesl opened this issue Aug 3, 2015 · 3 comments
Closed

[request] Multiple preload scripts #2406

mattdesl opened this issue Aug 3, 2015 · 3 comments

Comments

@mattdesl
Copy link
Contributor

mattdesl commented Aug 3, 2015

I am working on some low-level modules to help make CLI apps easier to write in Electron. Currently I am using the preload option to patch some things (like process.argv and window.onerror) to provide a nicer user experience. However, the end-user may want to attach their own preload scripts on top of this for their own specific needs.

The easiest way I can think of is to make the preload option to BrowserWindow accept a (String|Array). This way my low-level module can run its preload script before any of the end-users scripts.

What do you think? I might be able to help PR this feature.

@zcbenz
Copy link
Member

zcbenz commented Aug 4, 2015

The preload script is simply implemented by calling require('script/path'), if you want to allow users to setup their own preload scripts, I think the best way is to just implement it by calling require in your preload script.

@zcbenz zcbenz closed this as completed Aug 4, 2015
@mattdesl
Copy link
Contributor Author

mattdesl commented Aug 4, 2015

Thanks for the reply. 😄

Is there a clean way of sending the paths (synchronously) to the preload script, without polluting the end-user's ipc?

@zcbenz
Copy link
Member

zcbenz commented Aug 4, 2015

You can save the paths in a global variable in the main process, and use the remote module to read them. Another way is to save the paths to some configuration file, and use fs to read it.

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