Remove global shared state to fix unit tests (#5889)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-07-26 08:55:13 -04:00
1 parent bedc440d42
commit f61330611e
28 files changed
+44 -56

No files matched your search

@@ -3,8 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { SemVer } from "semver";
import appVersionInjectable from "../../get-configuration-file-model/app-version/app-version.injectable";
import appSemanticVersionInjectable from "../../vars/app-semantic-version.injectable";
import type { UpdateChannelId } from "../update-channels";
import { updateChannels } from "../update-channels";
@@ -12,12 +11,11 @@ const defaultUpdateChannelInjectable = getInjectable({
id: "default-update-channel",
instantiate: (di) => {
const appVersion = di.inject(appVersionInjectable);
const appSemanticVersion = di.inject(appSemanticVersionInjectable);
const currentReleaseChannel = appSemanticVersion.prerelease[0]?.toString();
const currentReleaseChannel = new SemVer(appVersion).prerelease[0]?.toString() as UpdateChannelId;
if (currentReleaseChannel && updateChannels[currentReleaseChannel]) {
return updateChannels[currentReleaseChannel];
if (currentReleaseChannel in updateChannels) {
return updateChannels[currentReleaseChannel as UpdateChannelId];
}
return updateChannels.latest;