Skip to content

Commit 1bc31f3

Browse files
fix(desktop): hydrate Nushell login shell environment
1 parent 89f091c commit 1bc31f3

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { listLoginShellCandidates, setWindowsPath } from "@t3tools/shared/shell";
1+
import {
2+
buildEnvironmentCaptureCommand,
3+
listLoginShellCandidates,
4+
setWindowsPath,
5+
} from "@t3tools/shared/shell";
26
import * as Context from "effect/Context";
37
import * as Duration from "effect/Duration";
48
import * as Effect from "effect/Effect";
@@ -199,17 +203,6 @@ const logShellEnvironmentCommandError = (
199203
}),
200204
);
201205

202-
const capturePosixEnvironmentCommand = (names: ReadonlyArray<string>) =>
203-
names
204-
.map((name) => {
205-
return [
206-
`printf '%s\\n' '${startMarker(name)}'`,
207-
`printenv ${name} || true`,
208-
`printf '%s\\n' '${endMarker(name)}'`,
209-
].join("; ");
210-
})
211-
.join("; ");
212-
213206
const captureWindowsEnvironmentCommand = (names: ReadonlyArray<string>) =>
214207
[
215208
"$ErrorActionPreference = 'Stop'",
@@ -320,7 +313,7 @@ const readLoginShellEnvironment = (
320313
: runCommandOutput({
321314
probe: "login-shell",
322315
command: shell,
323-
args: ["-ilc", capturePosixEnvironmentCommand(names)],
316+
args: ["-ilc", buildEnvironmentCaptureCommand(shell, names)],
324317
timeout: LOGIN_SHELL_TIMEOUT,
325318
}).pipe(Effect.map((output) => extractEnvironment(output, names)));
326319

‎packages/shared/src/shell.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,12 @@ function envCaptureEnd(name: string): string {
201201
return `__T3CODE_ENV_${name}_END__`;
202202
}
203203

204-
function isNushellExecutable(shell: string): boolean {
204+
export function buildEnvironmentCaptureCommand(
205+
shell: string,
206+
names: ReadonlyArray<string>,
207+
): string {
205208
const executableName = NodePath.basename(shell).toLowerCase();
206-
return executableName === "nu" || executableName === "nu.exe";
207-
}
208-
209-
function buildEnvironmentCaptureCommand(shell: string, names: ReadonlyArray<string>): string {
210-
const isNushell = isNushellExecutable(shell);
209+
const isNushell = executableName === "nu" || executableName === "nu.exe";
211210

212211
return names
213212
.map((name) => {

0 commit comments

Comments
 (0)