Skip to content

Commit

Permalink
fix: revert path transformation for windows/macos
Browse files Browse the repository at this point in the history
path.normalize() does not transform drive letters to lower case,
so we revert back to the original version.

Contributed on behalf of STMicroelectronics

Signed-off-by: Olaf Lessenich <[email protected]>
  • Loading branch information
xai committed Nov 14, 2023
1 parent ac79a36 commit 207c13b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/playwright/src/theia-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// *****************************************************************************

import * as fs from 'fs-extra';
import * as path from 'path';
import { resolve } from 'path';
import { OSUtil, urlEncodePath } from './util';

Expand All @@ -30,7 +29,7 @@ export class TheiaWorkspace {
* @param {string[]} pathOfFilesToInitialize Path to files or folders that shall be copied to the workspace
*/
constructor(protected pathOfFilesToInitialize?: string[]) {
this.workspacePath = fs.mkdtempSync(path.join(OSUtil.tmpDir, 'cloud-ws-'));
this.workspacePath = fs.mkdtempSync(`${OSUtil.tmpDir}${OSUtil.fileSeparator}cloud-ws-`);
}

/** Performs the file system operations preparing the workspace location synchronously. */
Expand All @@ -47,7 +46,15 @@ export class TheiaWorkspace {
}

get path(): string {
return path.normalize(this.workspacePath);
let workspacePath = this.workspacePath;
if (!OSUtil.osStartsWithFileSeparator(this.workspacePath)) {
workspacePath = `${OSUtil.fileSeparator}${workspacePath}`;
}
if (OSUtil.isWindows) {
// Drive letters in windows paths have to be lower case
workspacePath = workspacePath.replace(/.:/, matchedChar => matchedChar.toLowerCase());
}
return workspacePath;
}

get urlEncodedPath(): string {
Expand Down

0 comments on commit 207c13b

Please sign in to comment.