Repository navigation
Conversation
Magek.config was created when the module loaded, so MAGEK_ENV had to be set before import. Config is now created on first access. Magek.init(environment) sets the name before that. The MAGEK_ENV path still works. sinon replace on Magek.config has to become replaceGetter. Fixes theam#664
This branch has not been deployed
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.
Summary
Magek.configwas built when@magek/coreloaded, soMAGEK_ENVhad to be set before the import. Config is now created the first time it is read.Magek.init(environment)sets the name before that read. Ifinitis not called,MAGEK_ENVis still used.inithas to run before any module that uses Magek decorators orMagek.configureis evaluated. ESimportdeclarations are hoisted, so a call under those imports in the same file is too late.Calling
initagain with the same name does nothing. A different name throws, including when config was already built fromMAGEK_ENV.Semver: the version policy's next bump is still patch. This adds
Magek.initand keeps theMAGEK_ENVpath. It is not a silent upgrade for tests:Magek.configis a getter, and sinonreplace(Magek, 'config', config)throws. UsereplaceGetter(Magek, 'config', () => config).docs/content/advanced/testing.mdshows that.Fixes #664
Test plan
cd packages/core && rushx test(337 passing)cd packages/core && rushx lint:fixcd packages/server && rushx test(39 passing)