33
44import {
55 FileSystem ,
6- JsonFile ,
76 Terminal ,
87 ConsoleTerminalProvider ,
98 Path
@@ -14,13 +13,7 @@ import { EOL } from 'os';
1413import * as chokidar from 'chokidar' ;
1514
1615import { ILocFile } from './interfaces' ;
17- import { ResxReader } from './utilities/ResxReader' ;
18- import { Constants } from './utilities/Constants' ;
19- import {
20- Logging ,
21- ILoggingFunctions ,
22- ILoggerOptions
23- } from './utilities/Logging' ;
16+ import { ILoggerOptions } from './utilities/Logging' ;
2417import { LocFileParser } from './utilities/LocFileParser' ;
2518
2619/**
@@ -41,7 +34,6 @@ export interface ITypingsGeneratorOptions {
4134 */
4235export class TypingsGenerator {
4336 private _options : ITypingsGeneratorOptions ;
44- private _loggingFunctions : ILoggingFunctions ;
4537 private _loggingOptions : ILoggerOptions ;
4638
4739 public constructor ( options : ITypingsGeneratorOptions ) {
@@ -74,7 +66,6 @@ export class TypingsGenerator {
7466 writeError : this . _options . terminal . writeErrorLine . bind ( this . _options . terminal ) ,
7567 writeWarning : this . _options . terminal . writeWarningLine . bind ( this . _options . terminal )
7668 } ;
77- this . _loggingFunctions = Logging . getLoggingFunctions ( this . _loggingOptions ) ;
7869 }
7970
8071 public generateTypings ( ) : void {
@@ -84,42 +75,22 @@ export class TypingsGenerator {
8475 return path . resolve ( this . _options . srcFolder , fileToIgnore ) ;
8576 } ) ) ;
8677
87- const locJsonFilePaths : string [ ] = glob . sync (
88- path . join ( '**' , '*.loc.json' ) ,
89- {
90- root : this . _options . srcFolder ,
91- absolute : true
92- }
93- ) ;
94-
95- for ( let locJsonFilePath of locJsonFilePaths ) {
96- locJsonFilePath = path . resolve ( locJsonFilePath ) ;
97-
98- if ( filesToIgnore . has ( locJsonFilePath ) ) {
99- continue ;
100- }
101-
102- const locFileData : ILocFile = JsonFile . loadAndValidate ( locJsonFilePath , Constants . LOC_JSON_SCHEMA ) ;
103- this . _generateTypingsForLocFile ( locJsonFilePath , locFileData ) ;
104- }
105-
106- const resxFiles : string [ ] = glob . sync (
107- path . join ( '**' , '*.resx' ) ,
78+ const locFilePaths : string [ ] = glob . sync (
79+ path . join ( '**' , '*+(.resx|.loc.json)' ) ,
10880 {
10981 root : this . _options . srcFolder ,
11082 absolute : true
11183 }
11284 ) ;
11385
114- for ( let resxFilePath of resxFiles ) {
115- resxFilePath = path . resolve ( resxFilePath ) ;
86+ for ( let locFilePath of locFilePaths ) {
87+ locFilePath = path . resolve ( locFilePath ) ;
11688
117- if ( filesToIgnore . has ( resxFilePath ) ) {
89+ if ( filesToIgnore . has ( locFilePath ) ) {
11890 continue ;
11991 }
12092
121- const locFileData : ILocFile = ResxReader . readResxFileAsLocFile ( { ...this . _loggingFunctions , resxFilePath } ) ;
122- this . _generateTypingsForLocFile ( resxFilePath , locFileData ) ;
93+ this . _parseFileAndGenerateTypings ( locFilePath ) ;
12394 }
12495 }
12596
0 commit comments