Skip to content

Commit

Permalink
fix: change path.posix.join to path.join to resolve the path correctl…
Browse files Browse the repository at this point in the history
…y on wsl
  • Loading branch information
nguyenngoclongdev authored Oct 9, 2024
1 parent 5b3361b commit 2df1a8a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-crabs-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"terminal-keeper": patch
---

fix: change path.posix.join to path.join to resolve the path correctly on wsl
8 changes: 4 additions & 4 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fs } from '@vscode-utility/fs-browserify';
import { posix } from 'path';
import path from 'path';
import { workspace, WorkspaceConfiguration } from 'vscode';
import { getWorkspaceRootPath } from '../utils/get-workspace';
import { getTabWidth } from '../utils/utils';
Expand Down Expand Up @@ -162,11 +162,11 @@ export class Configuration {
}

private static getVscodeDirPath(workspaceDirPath: string): string {
return posix.join(workspaceDirPath, '.vscode');
return path.join(workspaceDirPath, '.vscode');
}

private static getSessionFilePath(workspaceDirPath: string): string {
const vscodeDirPath = this.getVscodeDirPath(workspaceDirPath);
return posix.join(vscodeDirPath, 'sessions.json');
return path.join(vscodeDirPath, 'sessions.json');
}
}
}
24 changes: 24 additions & 0 deletions src/utils/get-workspace.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fs } from '@vscode-utility/fs-browserify';
import { exec } from 'child_process';
import * as path from 'path';
import { promisify } from 'util';
Expand Down Expand Up @@ -41,3 +42,26 @@ export const getWorkspaceRootPath = async (uri?: Uri): Promise<string | undefine
const stat = await workspace.fs.stat(Uri.file(cwd));
return stat.type === FileType.File ? path.dirname(cwd) : cwd;
};

export const getRecursiveWorkspace = async (): Promise<string | undefined> => {
const { workspaceFolders } = workspace;
if (!workspaceFolders) {
return undefined;
}

let workspaceHasSessionsFile: string | undefined;
for (const folder of workspaceFolders) {
try {
const workspacePath = folder.uri.fsPath;
const sessionsFilePath = path.join(workspacePath, '.vscode', 'sessions.json');
const isExistSessionsFile = await fs.existAsync(sessionsFilePath);
if (isExistSessionsFile) {
workspaceHasSessionsFile = sessionsFilePath;
break;
}
} catch (error) {
console.log('No config in workspace', folder, error);
}
}
return workspaceHasSessionsFile;
};

0 comments on commit 2df1a8a

Please sign in to comment.