Skip to content

Commit

Permalink
fixup! fix: improve detection of Angular core version in monorepo setup
Browse files Browse the repository at this point in the history
Feedback
  • Loading branch information
devversion committed Nov 8, 2024
1 parent 8fb7829 commit 77c0aba
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ export class AngularLanguageClient implements vscode.Disposable {
}

// Sort the versions from oldest to newest.
const angularVersions = (await getAngularVersionsInWorkspace(this.outputChannel)).sort(
(a, b) => a.version.greaterThanOrEqual(b.version) ? 1 : -1);
const angularVersions = (await getAngularVersionsInWorkspace(this.outputChannel))
.sort((a, b) => a.version.greaterThanOrEqual(b.version) ? 1 : -1);

// Only disable block syntax if we find angular/core and every one we find does not support
// block syntax
Expand Down Expand Up @@ -552,10 +552,15 @@ function extensionVersionCompatibleWithAllProjects(serverModuleLocation: string)
}

/**
* Returns true if any project in the workspace supports block syntax (v17+).
* Traverses through the currently open VSCode workspace (i.e. all open folders)
* and finds all `@angular/core` versions installed based on `package.json` files.
*/
async function getAngularVersionsInWorkspace(outputChannel: vscode.OutputChannel): Promise<NodeModule[]> {
const packageJsonFiles = await vscode.workspace.findFiles("**/package.json", "**/node_modules/**");
async function getAngularVersionsInWorkspace(outputChannel: vscode.OutputChannel):
Promise<NodeModule[]> {
const packageJsonFiles = await vscode.workspace.findFiles(
'**/package.json',
// Skip looking inside `node_module` folders as those contain irrelevant files.
'**/node_modules/**');
const packageJsonRoots = packageJsonFiles.map(f => path.dirname(f.fsPath));
const angularCoreModules = new Set<NodeModule>();

Expand Down

0 comments on commit 77c0aba

Please sign in to comment.