Skip to content

Commit 1bd3813

Browse files
committed
Make the code work on every platform
Signed-off-by: David Gageot <[email protected]>
1 parent 3ea63f2 commit 1bd3813

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/extension/ui/src/utils/Files.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,31 @@ let user: string | null = null;
3636

3737
export const getUser = async (client: v1.DockerDesktopClient) => {
3838
if (user == null) {
39-
const result = await tryRunImageSync(client, [
40-
"--rm",
41-
"--network=none",
42-
"-e",
43-
"USER",
44-
BUSYBOX,
45-
"/bin/sh",
46-
"-c",
47-
client.host.platform === "win32"
48-
? `\"echo $USER\"`
49-
: `'echo $USER'`,
50-
]);
51-
user = result.trim();
39+
if (client.host.platform === "win32") {
40+
const result = await tryRunImageSync(client, [
41+
"--rm",
42+
"--network=none",
43+
"-e",
44+
"USERNAME",
45+
BUSYBOX,
46+
"/bin/sh",
47+
"-c",
48+
`\"echo $USERNAME\"`,
49+
]);
50+
user = result.trim();
51+
} else {
52+
const result = await tryRunImageSync(client, [
53+
"--rm",
54+
"--network=none",
55+
"-e",
56+
"USER",
57+
BUSYBOX,
58+
"/bin/sh",
59+
"-c",
60+
`'echo $USER'`,
61+
]);
62+
user = result.trim();
63+
}
5264
}
5365
return user;
5466
};

0 commit comments

Comments
 (0)