diff --git a/.changeset/light-crabs-jam.md b/.changeset/light-crabs-jam.md new file mode 100644 index 0000000..dffe770 --- /dev/null +++ b/.changeset/light-crabs-jam.md @@ -0,0 +1,5 @@ +--- +"terminal-keeper": patch +--- + +fix: change path.posix.join to path.join to resolve the path correctly on wsl diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index cfbf419..69d3396 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -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'; @@ -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'); } -} \ No newline at end of file +} diff --git a/src/utils/get-workspace.ts b/src/utils/get-workspace.ts index c424eeb..890e470 100644 --- a/src/utils/get-workspace.ts +++ b/src/utils/get-workspace.ts @@ -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'; @@ -41,3 +42,26 @@ export const getWorkspaceRootPath = async (uri?: Uri): Promise => { + 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; +};