@@ -4,7 +4,6 @@ import path from 'path';
44import { ReplexicaCompilerData , ReplexicaCompilerPayload } from "./compiler" ;
55import { ReplexicaLocaleData , ReplexicaConfig } from "./types" ;
66
7- const debugDir = '.debug/replexica' ;
87export class ReplexicaOutputProcessor {
98 public static create ( relativeFilePath : string , options : ReplexicaConfig ) {
109 return new ReplexicaOutputProcessor ( relativeFilePath , options ) ;
@@ -14,9 +13,12 @@ export class ReplexicaOutputProcessor {
1413 private readonly relativeFilePath : string ,
1514 private readonly options : ReplexicaConfig ,
1615 ) { }
16+
17+ private _outDir = path . join ( process . cwd ( ) , `node_modules/@replexica/translations` ) ;
18+ private _debugDir = path . join ( process . cwd ( ) , '.debug/replexica' ) ;
1719
1820 public saveData ( data : ReplexicaCompilerData ) {
19- const filePath = path . join ( process . cwd ( ) , this . options . outDir , '.replexica.json' ) ;
21+ const filePath = path . join ( this . _outDir , '.replexica.json' ) ;
2022 const existingData : ReplexicaCompilerPayload = this . _loadObject < ReplexicaCompilerPayload > ( filePath ) || this . _createEmptyCompilerPayload ( ) ;
2123 const newData = {
2224 ...existingData ,
@@ -31,7 +33,7 @@ export class ReplexicaOutputProcessor {
3133
3234 public saveSourceLocaleData ( data : ReplexicaCompilerData ) {
3335 const existingData : ReplexicaLocaleData =
34- this . _loadObject < ReplexicaLocaleData > ( path . join ( process . cwd ( ) , this . options . i18nDir , `${ this . options . sourceLocale } .json` ) ) ||
36+ this . _loadObject < ReplexicaLocaleData > ( path . join ( this . _outDir , `${ this . options . sourceLocale } .json` ) ) ||
3537 this . _createEmptyLocaleData ( ) ;
3638
3739 const newLocaleData : ReplexicaLocaleData = {
@@ -54,17 +56,17 @@ export class ReplexicaOutputProcessor {
5456 delete newLocaleData [ fileId ] ;
5557 }
5658 }
57- const filePath = path . join ( process . cwd ( ) , this . options . i18nDir , `${ this . options . sourceLocale } .json` ) ;
59+ const filePath = path . join ( this . _outDir , `${ this . options . sourceLocale } .json` ) ;
5860 this . _saveObject ( filePath , newLocaleData ) ;
5961 }
6062
6163 public saveAst ( ast : File ) {
62- const filePath = path . join ( process . cwd ( ) , debugDir , this . relativeFilePath + '.json' ) ;
64+ const filePath = path . join ( process . cwd ( ) , this . _debugDir , this . relativeFilePath + '.json' ) ;
6365 this . _saveObject ( filePath , ast ) ;
6466 }
6567
6668 public saveOutput ( output : string ) {
67- const filePath = path . join ( process . cwd ( ) , debugDir , this . relativeFilePath + '.txt' ) ;
69+ const filePath = path . join ( process . cwd ( ) , this . _debugDir , this . relativeFilePath + '.txt' ) ;
6870 this . _saveText ( filePath , output ) ;
6971 }
7072
0 commit comments