@@ -13,7 +13,12 @@ import { URI } from 'vscode-uri'
1313
1414const fs = require ( 'fs' ) . promises
1515const path = require ( 'path' )
16- const LIBRARY_DIR = path . join ( '//TODO FIXME' , 'indexing' )
16+ const LIBRARY_DIR = ( ( ) => {
17+ if ( require . main ) {
18+ return path . join ( dirname ( require . main . filename ) , 'indexing' )
19+ }
20+ return path . join ( __dirname , 'indexing' )
21+ } ) ( )
1722
1823export class LocalProjectContextController {
1924 private static instance : LocalProjectContextController | undefined
@@ -40,11 +45,16 @@ export class LocalProjectContextController {
4045
4146 public async init ( vectorLib ?: any ) : Promise < void > {
4247 try {
43- const vecLib = vectorLib ?? ( await import ( path . join ( LIBRARY_DIR , 'dist' , 'extension.js' ) ) )
44- const root = this . findCommonWorkspaceRoot ( this . workspaceFolders )
45- this . _vecLib = await vecLib . start ( LIBRARY_DIR , this . clientName , root )
46- await this . buildIndex ( )
47- LocalProjectContextController . instance = this
48+ const libraryPath = path . join ( LIBRARY_DIR , 'dist' , 'extension.js' )
49+ const vecLib = vectorLib ?? ( await import ( libraryPath ) )
50+ if ( vecLib ) {
51+ const root = this . findCommonWorkspaceRoot ( this . workspaceFolders )
52+ this . _vecLib = await vecLib . start ( LIBRARY_DIR , this . clientName , root )
53+ await this . buildIndex ( )
54+ LocalProjectContextController . instance = this
55+ } else {
56+ this . log . warn ( `Vector library could not be imported from: ${ libraryPath } ` )
57+ }
4858 } catch ( error ) {
4959 this . log . error ( 'Vector library failed to initialize:' + error )
5060 }
0 commit comments