Skip to content

Commit 98334a9

Browse files
authored
fix: normalize temporary directory path handling for remote environments (#5588)
* fix: normalize temporary directory path handling for remote environments * fix: use the more accurate logic --------- Co-authored-by: Sean Larkin <thelarkinn@users.noreply.github.com>
1 parent 7083889 commit 98334a9

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

  • vscode-extensions/playwright-local-browser-server-vscode-extension/src

vscode-extensions/playwright-local-browser-server-vscode-extension/src/extension.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,27 @@ const VSCODE_SETTINGS_EXTENSION_FILTER: string = `@ext:${EXTENSION_ID}`;
4040
async function writeExtensionInstalledFileAsync(terminal: ITerminal): Promise<void> {
4141
try {
4242
// If on a remote environment, write a file to os.tempdir() using workspace fs
43-
let tempDir: string;
43+
4444
let fileUri: vscode.Uri;
45+
let tempDir: string;
4546

4647
if (vscode.env.remoteName) {
47-
tempDir = await runWorkspaceCommandAsync({
48+
const markerPrefix: string = '<<<TEMPDIR_START>>>';
49+
const markerSuffix: string = '<<<TEMPDIR_END>>>';
50+
const output: string = await runWorkspaceCommandAsync({
4851
terminalOptions: { name: 'playwright-local-browser-server', hideFromUser: true },
49-
commandLine: `node -p "require('node:os').tmpdir()"`,
52+
commandLine: `node -p "'${markerPrefix}' + require('node:os').tmpdir() + '${markerSuffix}'"`,
5053
terminal
5154
});
5255

56+
const startIndex: number = output.indexOf(markerPrefix);
57+
const endIndex: number = output.indexOf(markerSuffix);
58+
if (startIndex !== -1 && endIndex !== -1 && endIndex > startIndex) {
59+
tempDir = output.substring(startIndex + markerPrefix.length, endIndex).trim();
60+
} else {
61+
throw new Error('Failed to parse temp directory from command output');
62+
}
63+
5364
// For remote environments, use the vscode-remote scheme
5465
// The workspace folder should have the correct scheme already
5566
const workspaceFolder: vscode.WorkspaceFolder | undefined = vscode.workspace.workspaceFolders?.[0];

0 commit comments

Comments
 (0)