-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Fix for issue 4820 #6053
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: main
Are you sure you want to change the base?
Fix for issue 4820 #6053
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { HostProcessHostname, HostProcessPlatform } from "@t3tools/shared/hostProcess"; | ||
| import { HostProcessEnvironment, HostProcessHostname, HostProcessPlatform } from "@t3tools/shared/hostProcess"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
| import * as Option from "effect/Option"; | ||
|
|
@@ -179,6 +179,55 @@ const resolveFriendlyHostLabel = Effect.fn("resolveFriendlyHostLabel")(function* | |
| return null; | ||
| }); | ||
|
|
||
| const isWslEnvironment = Effect.fn("isWslEnvironment")(function* () { | ||
| const platform = yield* HostProcessPlatform; | ||
| if (platform !== "linux") { | ||
| return false; | ||
| } | ||
|
|
||
| const fileSystem = yield* FileSystem.FileSystem; | ||
| const osReleasePath = "/proc/sys/kernel/osrelease"; | ||
|
|
||
| const content = yield* fileSystem.exists(osReleasePath).pipe( | ||
| Effect.mapError( | ||
| (cause) => | ||
| new ServerEnvironmentLabelFileError({ | ||
| operation: "inspect", | ||
| path: osReleasePath, | ||
| cause, | ||
| }), | ||
| ), | ||
| Effect.flatMap((exists) => | ||
| exists | ||
| ? fileSystem.readFileString(osReleasePath).pipe( | ||
| Effect.mapError( | ||
| (cause) => | ||
| new ServerEnvironmentLabelFileError({ | ||
| operation: "read", | ||
| path: osReleasePath, | ||
| cause, | ||
| }), | ||
| ), | ||
| ) | ||
| : Effect.succeed("") | ||
| ), | ||
| Effect.catchTags({ | ||
| ServerEnvironmentLabelFileError: (error) => | ||
| Effect.logDebug(error.message).pipe( | ||
| Effect.annotateLogs({ | ||
| operation: error.operation, | ||
| path: error.path, | ||
| cause: error, | ||
| }), | ||
| Effect.as(""), | ||
| ), | ||
| }), | ||
| ); | ||
|
macroscopeapp[bot] marked this conversation as resolved.
|
||
|
|
||
| const lowerContent = content.toLowerCase(); | ||
| return lowerContent.includes("microsoft") || lowerContent.includes("wsl"); | ||
| }); | ||
|
|
||
| export const resolveServerEnvironmentLabel = Effect.fn("resolveServerEnvironmentLabel")(function* ( | ||
| input: ResolveServerEnvironmentLabelInput, | ||
| ) { | ||
|
|
@@ -189,6 +238,15 @@ export const resolveServerEnvironmentLabel = Effect.fn("resolveServerEnvironment | |
|
|
||
| const hostname = normalizeLabel(yield* HostProcessHostname); | ||
| if (hostname) { | ||
| const isWsl = yield* isWslEnvironment(); | ||
| if (isWsl) { | ||
| const env = yield* HostProcessEnvironment; | ||
| const distroName = env["WSL_DISTRO_NAME"]; | ||
| if (distroName && distroName.trim().length > 0) { | ||
| return `${hostname} (WSL: ${distroName.trim()})`; | ||
| } | ||
| return `${hostname} (WSL)`; | ||
| } | ||
|
Comment on lines
+241
to
+249
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the resolved server environment label (a backend behavior change) but Posted via Macroscope — Effect Service Conventions |
||
| return hostname; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.