From 7c412cbb237577a20a8a8a629de86f3bcad59b56 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 30 Apr 2022 16:46:16 +0200 Subject: [PATCH] improvement: remove AdonisProject located in node_modules, close #2 --- src/Extension.ts | 12 +++++++++++- src/index.ts | 5 +---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Extension.ts b/src/Extension.ts index 70baa9a..45bc34f 100644 --- a/src/Extension.ts +++ b/src/Extension.ts @@ -1,5 +1,5 @@ import { basename } from 'path' -import { Uri } from 'vscode' +import { Uri, workspace } from 'vscode' export interface AdonisProject { path: string @@ -13,6 +13,16 @@ export default class Extension { */ public static adonisProjectPaths: string[] = [] + /** + * Scan the whole workspace(s) for existing Adonis projects + */ + public static async loadAdonisProjects() { + let files = await workspace.findFiles('**/ace', '**/node_modules/**', undefined) + files.map((file) => + Extension.adonisProjectPaths.push(file.path.split('/').slice(0, -1).join('/')) + ) + } + /** * Returns the directories */ diff --git a/src/index.ts b/src/index.ts index a2c9299..8545070 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,10 +11,7 @@ import { EdgeFormatterProvider } from './languages' import Extension from './Extension' export async function activate(context: ExtensionContext) { - let files = await workspace.findFiles('**/ace', undefined) - files.map((file) => - Extension.adonisProjectPaths.push(file.path.split('/').slice(0, -1).join('/')) - ) + await Extension.loadAdonisProjects() /** * Commands