File tree Expand file tree Collapse file tree
src/utilities/analytics/reference Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,9 +13,16 @@ export class ReferenceLoader {
1313 private dataDir : string ;
1414 private locale : string ;
1515
16- constructor ( dataDir : string = path . join ( __dirname , 'data' ) , locale : string = 'en' ) {
17- this . dataDir = dataDir ;
16+ constructor ( dataDir ?: string , locale : string = 'en' ) {
1817 this . locale = locale ;
18+
19+ if ( dataDir ) {
20+ this . dataDir = dataDir ;
21+ } else {
22+ // Resolve the data directory relative to this file's location
23+ // Use __dirname which works correctly after compilation
24+ this . dataDir = path . join ( __dirname , 'data' ) ;
25+ }
1926 }
2027
2128 /**
@@ -126,3 +133,25 @@ export class ReferenceLoader {
126133 } ;
127134 }
128135}
136+
137+ /**
138+ * Get the default reference data path
139+ */
140+ export function getReferenceDataPath ( ) : string {
141+ return path . join ( __dirname , 'data' ) ;
142+ }
143+
144+ /**
145+ * Check if reference data files exist
146+ */
147+ export function hasReferenceData ( ) : boolean {
148+ const dataPath = getReferenceDataPath ( ) ;
149+ const requiredFiles = [
150+ 'core_lists.en.json' ,
151+ 'common_words.en.json' ,
152+ 'sentences.en.json' ,
153+ 'synonyms.en.json' ,
154+ 'fringe.en.json' ,
155+ ] ;
156+ return requiredFiles . every ( ( file ) => fs . existsSync ( path . join ( dataPath , file ) ) ) ;
157+ }
You can’t perform that action at this time.
0 commit comments