diff --git a/src/analysis.ts b/src/analysis.ts index 35d1bb61..3ea0fbac 100644 --- a/src/analysis.ts +++ b/src/analysis.ts @@ -100,6 +100,7 @@ export async function analyzeFolders(options: FileAnalysisOptions): Promise { +async function getSupportedFiles( + baseURL: string, + source: string, + requestId?: string, + languages?: string[], +): Promise { emitter.supportedFilesLoaded(null); const resp = await getFilters(baseURL, source, undefined, requestId); if (resp.type === 'error') { throw resp.error; } - const supportedFiles = resp.value; - emitter.supportedFilesLoaded(supportedFiles); - return supportedFiles; + const supportedFilesFromApi = resp.value; + //Given supported languages from 'registy' + if (languages) { + let supportedFiles: SupportedFiles = {} as any; + supportedFiles.configFiles = supportedFilesFromApi.configFiles; + supportedFiles.extensions = languages; + //For verification only + supportedFiles.extensions = supportedFiles.extensions.filter(langExtension => + supportedFilesFromApi.extensions.includes(langExtension), + ); + emitter.supportedFilesLoaded(supportedFiles); + return supportedFiles; + } + emitter.supportedFilesLoaded(supportedFilesFromApi); + return supportedFilesFromApi; } export interface FileBundle extends RemoteBundle { @@ -208,10 +225,9 @@ export interface FileBundle extends RemoteBundle { */ export async function createBundleFromFolders(options: CreateBundleFromFoldersOptions): Promise { const baseDir = determineBaseDir(options.paths); - const [supportedFiles, fileIgnores] = await Promise.all([ // Fetch supporte files to save network traffic - getSupportedFiles(options.baseURL, options.source, options.requestId), + getSupportedFiles(options.baseURL, options.source, options.requestId, options.languages), // Scan for custom ignore rules collectIgnoreRules(options.paths, options.symlinksEnabled, options.defaultFileIgnores), ]); diff --git a/src/interfaces/analysis-options.interface.ts b/src/interfaces/analysis-options.interface.ts index 37dd4fd3..ccab1c4d 100644 --- a/src/interfaces/analysis-options.interface.ts +++ b/src/interfaces/analysis-options.interface.ts @@ -43,12 +43,14 @@ export interface FileAnalysisOptions extends AnalysisContext { connection: ConnectionOptions; analysisOptions: AnalysisOptions; fileOptions: AnalyzeFoldersOptions; + languages?: string[]; } export interface AnalyzeFoldersOptions { paths: string[]; symlinksEnabled?: boolean; defaultFileIgnores?: string[]; + languages?: string[]; } export interface CollectBundleFilesOptions extends AnalyzeFoldersOptions {