Skip to content

Commit

Permalink
fix: path resolve incorrect in multiple workspaces
Browse files Browse the repository at this point in the history
close #1679
  • Loading branch information
johnsoncodehk committed Aug 27, 2022
1 parent 35d7579 commit a034d1b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/vue-language-server/src/projects.ts
Expand Up @@ -270,6 +270,8 @@ export function createProjects(
}
}

let currentCwd = '';

function createWorkspace(
runtimeEnv: RuntimeEnvironment,
languageConfigs: LanguageConfigs,
Expand All @@ -288,18 +290,17 @@ function createWorkspace(
const projects = shared.createPathMap<Project>();
let inferredProject: Project | undefined;

const getRootPath = () => rootPath;
const _workspaceSys = ts.sys.getCurrentDirectory() === rootPath ? ts.sys : new Proxy(ts.sys, {
const _workspaceSys = new Proxy(ts.sys, {
get(target, prop) {
const fn = target[prop as keyof typeof target];
if (typeof fn === 'function') {
return new Proxy(fn, {
apply(target, thisArg, args) {
const cwd = process.cwd;
process.cwd = getRootPath;
const result = (target as any).apply(thisArg, args);
process.cwd = cwd;
return result;
if (currentCwd !== rootPath) {
process.chdir(rootPath);
currentCwd = rootPath;
}
return (target as any).apply(thisArg, args);
}
});
}
Expand Down

0 comments on commit a034d1b

Please sign in to comment.