Skip to content

Commit 0aafc62

Browse files
committed
chore: improve workspace building logs
1 parent c298386 commit 0aafc62

5 files changed

Lines changed: 17 additions & 8 deletions

File tree

packages/language-core/src/workspace.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ export class WorkspaceContext {
9292
this.packageManager = await this.adapter.detectPackageManager(this.rootPath)
9393

9494
if (this.packageManager !== 'npm') {
95-
const workspaceFilename = workspaceFileMapping[this.packageManager]
96-
this.workspaceFilePath = `${this.rootPath}/${workspaceFilename}`
95+
this.workspaceFilePath = join(this.rootPath, workspaceFileMapping[this.packageManager])
9796
this.#catalogs.resolve(
9897
await this.adapter.fileExists(this.workspaceFilePath)
9998
? (await this.loadWorkspaceFileInfo(this.workspaceFilePath))?.catalogs

packages/language-server/src/workspace.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ function createLanguageServerAdapter(folderUri: URI, connection: Connection, ser
3737
}
3838
},
3939

40-
async detectPackageManager(): Promise<'npm' | 'pnpm' | 'yarn'> {
40+
async detectPackageManager(rootPath): Promise<'npm' | 'pnpm' | 'yarn'> {
4141
try {
4242
const result = await connection.sendRequest(getPackageManagerRequestType, {
43-
uri: folderUri.toString(),
43+
uri: rootPath,
4444
})
4545
return result || 'npm'
4646
} catch {
@@ -106,13 +106,14 @@ export class WorkspaceState implements IWorkspaceState {
106106
[URI]
107107
>(
108108
async (folderUri) => {
109-
this.#connection.console.info(`[workspace-context] built ${folderUri.path}`)
110-
this.#cachedFolderPaths.add(folderUri.path)
111-
112-
return await WorkspaceContext.create(
109+
const ctx = await WorkspaceContext.create(
113110
folderUri.path,
114111
createLanguageServerAdapter(folderUri, this.#connection, this.#server),
115112
)
113+
this.#cachedFolderPaths.add(folderUri.path)
114+
115+
this.#connection.console.info(`[workspace-context] built for ${folderUri}, packageManager: ${ctx.packageManager}`)
116+
return ctx
116117
},
117118
{
118119
name: 'workspace-context',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"npm.packageManager": "npm"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"npm.packageManager": "pnpm"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"npm.packageManager": "yarn"
3+
}

0 commit comments

Comments
 (0)