Conversation
Jarod42
reviewed
Jul 14, 2022
Jarod42
reviewed
Jul 15, 2022
| @@ -0,0 +1,31 @@ | |||
| -- | |||
Member
There was a problem hiding this comment.
This should probably be named "test_globals.lua" to match the name of the file we are testing.
Contributor
Author
There was a problem hiding this comment.
File was named based on existing test named "tests/base/test_module_loader.lua"
| return mod | ||
| end) | ||
|
|
||
| function requireopt(modname, versions) |
Member
There was a problem hiding this comment.
Documentation? I'm not completely sold on "requireopt", as that feels like an oxymoron to me. What about "tryrequire"?
Contributor
Author
There was a problem hiding this comment.
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 <Jarod42@users.noreply.github.com>
592b144 to
a52c3c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)