-
-
Notifications
You must be signed in to change notification settings - Fork 640
Requireopt #1905
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
base: master
Are you sure you want to change the base?
Requireopt #1905
Conversation
| @@ -0,0 +1,31 @@ | |||
| -- | |||
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.
This should probably be named "test_globals.lua" to match the name of the file we are testing.
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.
File was named based on existing test named "tests/base/test_module_loader.lua"
| return mod | ||
| end) | ||
|
|
||
| function requireopt(modname, versions) |
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.
Documentation? I'm not completely sold on "requireopt", as that feels like an oxymoron to me. What about "tryrequire"?
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 agree. It was named requireopt in an effort to follow existing naming convention, based on the existing dofilepot.
IMO, both of them should be renamed try<thing>
Add a thired argument to the Premake require(modname, version, silent) function to disable error throwing when module failed to load. Add requireopt(m, v) as a shorthand for require(m, v, true)
Co-authored-by: Joris Dauphin <[email protected]>
Co-authored-by: Joris Dauphin <[email protected]>
Co-authored-by: Joris Dauphin <[email protected]>
592b144 to
a52c3c0
Compare
What does this PR do?
Adds new API
requireopt()to require a module without throwing an errorHow does this PR change Premake's behavior?
Also adds a third argument
silentto the existingrequire()(default: false)Anything else we should know?
Use case: Have a way to handle optional modules.
Example
Did you check all the boxes?
closes #XXXXin comment to auto-close issue when PR is merged)